public bool Add(ViewModel.AnnouncementViewModel announcement) { var account = new Intranet.Common.AccountInfo(); var fullName = account.GetFullName(); var ann = new HomePageAnnouncement() { AnnouncementContent = announcement.AnnouncementContent, StartDate = announcement.StartDate, EndDate = announcement.EndDate, IsApproved = false, IsActive = announcement.IsActive, ApproverName = announcement.ApproverName, IsDeleted = false, CreatedDate = DateTime.Now, CreatedBy = fullName, LastUpdatedDate = DateTime.Now, LastUpdatedBy = fullName, }; var insertedRec = AnnouncementService.InsertHomePageAnnouncement(ann); var notification = new Notification() { ReciverName = announcement.ApproverName, SenderName = fullName, CreatedBy = fullName, LastUpdatedBy = fullName, LastUpdatedDate = DateTime.Now, CreatedDate = DateTime.Now, RecordId = insertedRec.Id, ModuleName = "Announcement", IsApproved = false }; NotificationService.InsertNotification(notification); SendStatusUpdateEmail(announcement, announcement.ApproverName, true, fullName); return true; }
public bool Update(ViewModel.AnnouncementViewModel announcement) { var account = new Intranet.Common.AccountInfo(); var fullName = account.GetFullName(); var ann = new HomePageAnnouncement() { Id = announcement.Id, AnnouncementContent = announcement.AnnouncementContent, StartDate = announcement.StartDate, EndDate = announcement.EndDate, IsApproved = announcement.IsApproved, IsActive = announcement.IsActive, ApproverName = announcement.ApproverName, IsDeleted = false, CreatedDate = announcement.CreatedDate, CreatedBy = announcement.CreatedBy, LastUpdatedDate = DateTime.Now, LastUpdatedBy = fullName, }; var updatedRec = AnnouncementService.UpdateHomePageAnnouncement(ann); if (!announcement.IsApproved) { var notificationExited = NotificationService.GetAllNotificationByRecoedId("Announcement", announcement.Id); NotificationService.DeleteNotification(notificationExited); var notification = new Notification() { ReciverName = announcement.ApproverName, SenderName = fullName, CreatedBy = announcement.CreatedBy, LastUpdatedBy = fullName, LastUpdatedDate = DateTime.Now, CreatedDate = announcement.CreatedDate, RecordId = announcement.Id, ModuleName = "Announcement", IsApproved = false }; NotificationService.InsertNotification(notification); SendStatusUpdateEmail(announcement, announcement.ApproverName, false, announcement.CreatedBy); } else { var notificationExited = NotificationService.GetAllNotificationByRecoedId("Announcement", announcement.Id); if (notificationExited != null) NotificationService.DeleteNotification(notificationExited); var notification = new Notification() { ReciverName = announcement.CreatedBy, SenderName = announcement.ApproverName, CreatedBy = announcement.CreatedBy, LastUpdatedBy = fullName, LastUpdatedDate = DateTime.Now, CreatedDate = announcement.CreatedDate, RecordId = announcement.Id, ModuleName = "Announcement", IsApproved = true }; NotificationService.InsertNotification(notification); SendStatusUpdateEmail(announcement, announcement.CreatedBy, false, announcement.CreatedBy); } return AnnouncementService.UpdateHomePageAnnouncement(ann); }