public async Task <IActionResult> Reply(Guid id, [FromForm] ReplyRecieveModel model) { var reply = _mapper.Map <Reply>(model); reply.AuthorId = Guid.Parse(User.Identity.Name); try { await _imageService.GetSingleImage(Request.Form.Files, "replyImg"); } catch (AppException) { } return(Ok(await _replyService.Reply((await _questionService.GetQuestionWithRepliesById(id)).Replies, reply))); }
public async Task <IActionResult> EditReply(Guid id, [FromForm] ReplyRecieveModel model) { var reply = _mapper.Map <Reply>(model); reply.Id = id; reply.AuthorId = User.IsInRole("Admin") ? Guid.Empty : Guid.Parse(User.Identity.Name); try { await _replyService.Update(reply); return(Ok()); } catch (AppException ex) { return(BadRequest(new { message = ex.Message })); } }
public async Task <IActionResult> ReplyToReply(Guid id, [FromForm] ReplyRecieveModel model) { var reply = _mapper.Map <Reply>(model); reply.AuthorId = Guid.Parse(User.Identity.Name); try { await _imageService.GetSingleImage(Request.Form.Files, "replyImg"); } catch (AppException) { } try { var target = await _replyService.GetById(id); reply.TopQuestionId = target.TopQuestionId; reply.TopNoteId = target.TopNoteId; return(Ok(await _replyService.Reply(target.Replies, reply))); } catch (AppException ex) { return(NotFound(new { message = ex.Message })); } }