public async Task <IActionResult> AddAnswer(int id, string comment) { try { if (String.IsNullOrEmpty(comment)) { return(Json(false)); } var user = await _requestUserProvider.GetCurrentUserAsync(); var commentModel = new Answer() { Description = comment, Date = DateTime.Now, AuthorId = user.Id, QuestionId = id, }; await _answersCommand.AnswerQuestion(commentModel, new CancellationToken()); return(Json(true)); } catch (Exception ex) { var msg = ex.Message; return(Json(false)); } }
public Task UploadImage(IFormFile file) { var currentUser = _requestUserProvider.GetCurrentUserAsync().Result; if (currentUser == null) { throw new Exception("User not found"); } currentUser.UserPhoto = ConvertToBytes(file); return(_questionGateway.UploadUserPhoto(currentUser)); }