public void AddComment(CommentRegistrationPM commentRegistrationPM, UserIdentity userIdentity) { Notification notification = null; var comment = commentRegistrationPM.GetComment(); var contentAuthorId = ContentBiz.Read(c => c.Id == comment.ContentId).Select(c => c.AuthorId).Single(); comment.SenderId = userIdentity.UserId; CommentBiz.AddComment(comment); if (userIdentity.UserId != contentAuthorId) { notification = NotificationBiz.Add(NotificationType.WriteComment, userIdentity.UserId, comment.ContentId, contentAuthorId); } UnitOfWork.SaveChanges(); commentRegistrationPM.Id = comment.Id; commentRegistrationPM.CreateDate = comment.CreateDate; if (notification != null) { PushNotification.Send(contentAuthorId, PushNotificationType.NewNotification, NotificationBiz.ProcessNotification(notification).GetNotificationPM()); } }
public static Comment GetComment(this CommentRegistrationPM commentRegistrationPM) { return(AutoMapper.Mapper.Map <CommentRegistrationPM, Comment>(commentRegistrationPM)); }
public ActionResult AddComment(CommentRegistrationPM comment) { CommentService.AddComment(comment, User); return(Json(new { Id = comment.Id, CreateDate = comment.CreateDate.Value.ToPersianDate("g") })); }