public virtual PartialViewResult Delete() { var deleteCommentId = FullContext.Value.EntityId.Value; var commentsTarget = FullContext.GetCommentsTarget(); var targetEntityId = commentsTarget.EntityId.Value; var comment = _commentsService.Get(deleteCommentId); if (!_commentsService.CanDelete(comment, _intranetMemberService.GetCurrentMemberId())) { return(OverView(comment.ActivityId)); } var command = new RemoveCommentCommand(FullContext, deleteCommentId); _commandPublisher.Publish(command); switch (commentsTarget.Type.ToInt()) { case int type when ContextExtensions.HasFlagScalar(type, ContextType.Activity | ContextType.PagePromotion): var activityCommentsInfo = GetActivityComments(targetEntityId); return(OverView(activityCommentsInfo)); default: return(OverView(comment.ActivityId)); } }
public virtual PartialViewResult Add(CommentCreateModel model) { var commentsTarget = FullContext.GetCommentsTarget(); var targetEntityId = commentsTarget.EntityId.Value; if (!ModelState.IsValid) { return(OverView(targetEntityId)); } var createDto = MapToCreateDto(model, targetEntityId); var command = new AddCommentCommand(FullContext, createDto); _commandPublisher.Publish(command); OnCommentCreated(createDto.Id); switch (commentsTarget.Type.ToInt()) { case int type when ContextExtensions.HasFlagScalar(type, ContextType.Activity | ContextType.PagePromotion): var activityCommentsInfo = GetActivityComments(targetEntityId); return(OverView(activityCommentsInfo)); default: return(OverView(targetEntityId)); } }
public virtual PartialViewResult Edit(CommentEditModel model) { var editCommentId = FullContext.Value.EntityId.Value; var commentsTarget = FullContext.GetCommentsTarget(); var targetEntityId = commentsTarget.EntityId.Value; if (!ModelState.IsValid) { return(OverView(editCommentId)); } var comment = _commentsService.Get(editCommentId); if (!_commentsService.CanEdit(comment, _intranetUserService.GetCurrentUserId())) { return(OverView(editCommentId)); } var editDto = MapToEditDto(model, editCommentId); var command = new EditCommentCommand(FullContext, editDto); _commandPublisher.Publish(command); switch (commentsTarget.Type.ToInt()) { case int type when ContextExtensions.HasFlagScalar(type, ContextType.Activity | ContextType.PagePromotion): var activityCommentsInfo = GetActivityComments(targetEntityId); return(OverView(activityCommentsInfo)); default: return(OverView(comment.ActivityId)); } }
public BroadcastResult Handle(AddLikeCommand command) { var likeTarget = command.Context.Value; var likeTargetEntityId = likeTarget.EntityId.Value; switch (likeTarget.Type.ToInt()) { case (int)ContextType.Comment: var commentsTarget = command.Context.GetCommentsTarget(); if (ContextExtensions.HasFlagScalar(commentsTarget.Type, ContextType.Activity | ContextType.PagePromotion | ContextType.ContentPage)) { var service = _activitiesServiceFactory.GetNotifyableService(commentsTarget.EntityId.Value); service.Notify(likeTargetEntityId, NotificationTypeEnum.CommentLikeAdded); } break; case int type when ContextExtensions.HasFlagScalar(type, ContextType.Activity): var notifiableService = _activitiesServiceFactory.GetNotifyableService(likeTargetEntityId); notifiableService.Notify(likeTargetEntityId, NotificationTypeEnum.ActivityLikeAdded); break; } return(BroadcastResult.Success); }
private void UpdateCache(Enum commentsTargetType, Guid commentsTargetEntityId) { if (ContextExtensions.HasFlagScalar(commentsTargetType, ContextType.Activity | ContextType.PagePromotion)) { var activityService = _activitiesServiceFactory.GetCacheableIntranetActivityService(commentsTargetEntityId); activityService.UpdateActivityCache(commentsTargetEntityId); } }
public BroadcastResult Handle(EditCommentCommand command) { var commentsTarget = command.Context.GetCommentsTarget(); var commentsTargetEntityId = commentsTarget.EntityId.Value; if (ContextExtensions.HasFlagScalar(commentsTarget.Type, ContextType.Activity)) { var notifiableService = _activitiesServiceFactory.GetNotifyableService(commentsTargetEntityId); notifiableService.Notify(command.EditDto.Id, NotificationTypeEnum.CommentEdited); } return(BroadcastResult.Success); }
public BroadcastResult Handle(AddCommentCommand command) { var commentsTarget = command.Context.GetCommentsTarget(); var commentsTargetEntityId = commentsTarget.EntityId.Value; if (ContextExtensions.HasFlagScalar(commentsTarget.Type, ContextType.Activity | ContextType.PagePromotion | ContextType.ContentPage)) { var notifiableService = _activitiesServiceFactory.GetNotifyableService(commentsTargetEntityId); var notificationType = command.CreateDto.ParentId.HasValue ? NotificationTypeEnum.CommentReplied : NotificationTypeEnum.CommentAdded; notifiableService.Notify(command.CreateDto.ParentId ?? command.CreateDto.Id, notificationType); } return(BroadcastResult.Success); }
public static bool StartsWith(this ContextData contextData, Enum firstPtr) => ContextExtensions.HasFlagScalar(firstPtr, contextData.Type);