public async Task <ActionResult> UpdateSecurityQuestion([FromBody] UpdateSecurityQuestionReqModel model) { if (!ModelState.IsValid) { return(BadRequest(new ErrorModel { Message = string.Join(",", ModelState.Values.SelectMany(v => v.Errors)) })); } var res = await _authService.UpdateSecurityQuestion(model, _authHelpers.GetCurrentUserId()); return(StatusCode(res.GetStatusCode(), res.Result)); }
public async Task <ServiceResponseResult> UpdateSecurityQuestion(UpdateSecurityQuestionReqModel model, long?userId) { Logger.WriteInformation("Updating securrity questions."); var user = await _context.User.FirstOrDefaultAsync(x => x.Id == userId); user = user.UpdateSecurityQuestion(model.Question) .UpdateSecurityQuestionAnswer(model.Answer) .UpdateLastUpdatedOn(DateTime.UtcNow) .UpdateLastUpdatedBy(user.Id); _context.User.Update(user); await _context.SaveChangesAsync(); return(new ServiceResponseResult { StatusCode = System.Net.HttpStatusCode.OK }); }