Guest User

Untitled

a guest
Apr 6th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. [Produces("application/json")]
  2. [Route("api/Audit")]
  3. public class AuditController : Controller
  4. {
  5. private IConfiguration _configuration;
  6. private CommomUtility util;
  7. private Login Login;
  8.  
  9. public AuditController(IConfiguration configuration)
  10. {
  11. _configuration = configuration;
  12. util = new CommomUtility(configuration);
  13. Login = new Login(configuration);
  14. }
  15.  
  16. [HttpPost]
  17. public JsonResult Action([FromBody] List<Dictionary<string, string>> li)
  18. {
  19. DataTable dt = new DataTable();
  20. string jsonString = string.Empty;
  21. try
  22. {
  23. if (li[0]["ActionMethod"].Equals("CheckLogin", StringComparison.InvariantCultureIgnoreCase))
  24. {
  25. dt = Login.checkLogin(li);
  26. }
  27. }
  28. catch (Exception ex)
  29. {
  30. }
  31. finally
  32. {
  33. dt.TableName = "Result";
  34. jsonString = util.DataTableToJson(dt);
  35. }
  36. return Json(JObject.Parse(jsonString));
  37. }
  38. }
  39.  
  40. import { Component, OnInit } from '@angular/core';
  41. import { HttpClient,HttpClientModule,HttpParams } from '@angular/common/http';
  42.  
  43. @Component({
  44. selector: 'app-login',
  45. templateUrl: './login.component.html',
  46. styleUrls: ['./login.component.css']
  47. })
  48. export class LoginComponent implements OnInit {
  49. username: string="";
  50. password: string="";
  51. loginBtnText: string='Log In';
  52. clearBtnText: string='Reset Fields';
  53. message:string;
  54. cssClass:string;
  55.  
  56. constructor(private http:HttpClient ) { }
  57.  
  58. ngOnInit() {
  59. }
  60.  
  61. checkLogIn(){
  62. const params = new HttpParams();
  63. params.set('ActionMethod', 'CheckLogin');
  64. params.set('StaffCode', '15989');
  65. params.set('Password', 'a$a#');
  66.  
  67. debugger
  68. var v= this.http.post("http://localhost:57863/api/Audit/",
  69. params,
  70. )
  71. .subscribe(data =>
  72. {alert('ok');},
  73. error =>
  74. {alert("Error");}
  75. );
  76. }
  77.  
  78. clearFields(){
  79. this.username="";
  80. this.password="";
  81. this.message="";
  82. }
  83.  
  84. }
Add Comment
Please, Sign In to add comment