public async Task <ActionResult> Post([FromBody] UserCommentUpdateDto model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var circleTopic = await _repo.GetCircleTopic(model.OwnerRecordId); if (circleTopic == null) { return(NotFound()); } if (!await this.MatchAppUserWithToken(model.AppUserId) || !await _repo.IsMember((int)model.AppUserId, circleTopic.CircleId)) { return(Unauthorized()); } // model.CircleId = circleTopic.CircleId; var newTopic = this._mapper.Map <CircleTopicComment>(model); newTopic.CircleId = circleTopic.CircleId; _repo.Add(newTopic); await _repo.SaveAll(); return(CreatedAtRoute("GetCircleTopicComment", new { id = model.Id }, _mapper.Map <CircleTopicCommentForReturnDto>(newTopic))); }
public async Task <ActionResult> Put([FromBody] UserCommentUpdateDto model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var circleEventCommentFromRepo = await this._repo.GetCircleEventComment(model.Id); if (circleEventCommentFromRepo == null) { return(NotFound()); } if (!await MatchAppUserWithToken((int)circleEventCommentFromRepo.AppUserId)) { return(Unauthorized()); } circleEventCommentFromRepo.Comment = model.Comment; //_mapper.Map(model, circleEventCommentFromRepo); try { await _repo.SaveAll(); } catch (System.Exception ex) { return(BadRequest("Failed to update circle topic comment: " + ex.Message)); } return(Ok()); }