public IActionResult LogInUser([FromBody] AuthenticateModel model) { string error = ""; if (string.IsNullOrEmpty(model.Email)) { error = " Email is null"; return(BadRequest(new { message = error })); } if (string.IsNullOrEmpty(model.Password)) { error = " Password is null"; return(BadRequest(new { message = error })); } if (!((validateMethods.CheckRegEx_UserName(model.Email)) && (model.Email.Length > validateMethods.LengthEmail) && (model.Email.Length < 50))) { error = " Email is Invalid!"; return(BadRequest(new { message = error })); } if (!((validateMethods.CheckRegEx_Password(model.Password)) && (model.Password.Length > validateMethods.LengthPassword) && (model.Password.Length < 50))) { if (error != "") { error = " Email and Password is Invalid! "; return(BadRequest(new { message = error })); } else { error = " Password is Invalid!"; return(BadRequest(new { message = error })); } } //Call Api Check email and Password if (error == "") { try { var user = _marchantService.LogIn(model.Email, model.Password); if (user == null) { return(BadRequest(new { message = "Not Found" })); } return(Ok(user)); } catch (Exception ex) { error = ex.Message; } return(BadRequest(new { message = error })); } else { return(BadRequest(new { message = error })); } }
public DetailMarchantDto LogIn(string email, string password) { var result = marchantService.LogIn(email, password); DetailMarchantDto detailMargent = new DetailMarchantDto() { Id = result.Id, AccountEWallet = result.AccountEWallet, NameShop = result.NameShop }; return(detailMargent); //throw new NotImplementedException(); }