public bool CreateComment(QuizzCommentModel model) { try { model.AuthorId = _currentUser.Id; model.PostedDate = DateTime.UtcNow; var entity = MappingUtil.Map <QuizzCommentModel, QuizzComment>(model); _uow.QuizzComments.Add(entity); _notificationSvc.QuizzNotificationSvc.AddQuizzCommentNotification(model.QuizzId, false); _uow.SaveChanges(); model.Id = entity.Id; model.AuthorName = _currentUser.UserName; model.PostedDate = entity.PostedDate; _notificationSvc.DepQuizzCommentNotificationSvc.AddDepPostCommentNotification(model.Id, false); _notificationSvc.DepQuizzNotificationSvc.AddDepQuizzReceiveCommentNotification(model.QuizzId, false); _activitySvc.QuizzCommentActivitySvc.AddQuizzCommentCreateActivity(model.QuizzId, model.Id, false); _activitySvc.QuizzCommentActivitySvc.AddQuizzReceiveCommentActivity(model.QuizzId, model.Id, false); _uow.SaveChanges(); return(true); } catch (Exception ex) { _loggingSvc.Log(ex); return(false); } }
public HttpResponseMessage Patch([FromBody] QuizzCommentModel model) { try { if (ModelState.IsValid == false || _quizzCommentSvc.UpdateComment(model) == false) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } return(Request.CreateResponse(HttpStatusCode.OK)); } catch (ServiceException ex) { return(Request.CreateResponse(ex.HttpStatusCode, ex.Message)); } }
public bool UpdateComment(QuizzCommentModel model) { try { var entity = MappingUtil.Map <QuizzCommentModel, QuizzComment>(model); _uow.QuizzComments.Update(entity); _uow.SaveChanges(); return(true); } catch (Exception ex) { _loggingSvc.Log(ex); return(false); } }
public bool CreateComment(QuizzCommentModel model) { try { var entity = MappingUtil.Map <QuizzCommentModel, QuizzComment>(model); _uow.QuizzComments.Add(entity); _notificationSvc.AddQuizzCommentNotification(model.QuizzId, false); _uow.SaveChanges(); model.Id = entity.Id; return(true); } catch (Exception ex) { _loggingSvc.Log(ex); return(false); } }
public bool UpdateComment(QuizzCommentModel model) { try { var entity = _uow.QuizzComments.GetById(model.Id); entity.Comment = model.Comment; _uow.QuizzComments.Update(entity); _notificationSvc.DepQuizzCommentNotificationSvc.AddDepPostedCommentModifiedNotification(model.Id, false); _activitySvc.QuizzCommentActivitySvc.AddQuizzCommentModifyActivity(model.QuizzId, model.Id, false); _uow.SaveChanges(); return(true); } catch (Exception ex) { _loggingSvc.Log(ex); return(false); } }
public void UpdateModel(QuizzCommentModel model) { SetAge(model); if (model.AuthorId == _currentUser.Id) { model.IsQuizzmate = true; model.IsAuthor = true; model.CanEdit = true; } else { var childIds = _currentUser.AsUserDependents.Select(ud => ud.ChildId) .ToList(); model.CanEdit = childIds.Contains(model.AuthorId); } model.AuthorName = model.IsQuizzmate ? model.AuthorFullName : model.AuthorUserName; model.AuthorUserName = ""; model.AuthorFullName = ""; model.PostedDate = model.PostedDate.ToLocalTime(); }