public async Task <IActionResult> Post([FromBody] Verification verification) { if (verification == null) { return(this.ApiErrorResponse(Constants.VerifiactionIsNull)); } using (var usersBl = new UsersBL(App.ConnectionString)) { var response = new Response(); var user = await usersBl.GetUserById(verification.UserId); if (user == null) { return(this.ApiErrorResponse(HttpStatusCode.BadRequest, ResponseCode.UserNotExist)); } verification.Code = App.CodeGenerator.GenerateKey(24); var v = await usersBl.CreateVerificationForUser(verification); if (v == null) { return(this.ApiErrorResponse(Messages.DbError)); } if (!await App.Mailer.Send(user.Email, v.Code)) { return(this.ApiErrorResponse(HttpStatusCode.Conflict, ResponseCode.UnableToSendMail)); } return(this.ApiSuccessResponse()); } }