public async Task <ActionResult> Post([FromRoute] long locationId, [FromBody][Required] AuthCodeCreateReqModel model) { if (!ModelState.IsValid) { return(BadRequest(new ErrorModel { Message = string.Join(",", ModelState.Values.SelectMany(v => v.Errors.Select(y => y.ErrorMessage))) })); } var res = await _authenticationCodeService.SendCode(model, _authHelpers.GetCurrentUserId().Value, locationId); return(StatusCode(res.GetStatusCode(), res.Result)); }
public async Task <ServiceResponseResult> SendCode(AuthCodeCreateReqModel model, long userId, long locationId) { Logger.WriteInformation("Sending auth code data."); var user = await _context.User.FirstOrDefaultAsync(x => x.Id == userId); var emailData = await _emailService.ConstructAuthCodeSending(model.Code); await _emailSender.SendMailViaSmtpClientAsync(new string[] { user.Email }, new string[] { }, new string[] { }, emailData); return(new ServiceResponseResult { StatusCode = System.Net.HttpStatusCode.OK }); }