protected NotificationDto CreateNotificationDto(Notification notification) { NotificationDto notificationDto = new NotificationDto(); string projectName = (from p in _context.Project where p.Id == notification.ProjectId select p.ProjectName).FirstOrDefault(); notificationDto.projectName = projectName; notificationDto.Id = notification.NotificationSapId; notificationDto.description = notification.Description; notificationDto.creationDate = notification.CreationDate.ToString("yyyy-MM-dd"); if (notification.EstEndDate == nullDate) { notificationDto.endDate = null; } else { notificationDto.endDate = notification.EstEndDate.ToString("yyyy-MM-dd"); } notificationDto.status = notification.Status; notificationDto.partners = GetAllNotificationPartners(notification); return(notificationDto); }
public IEnumerable <NotificationDto> GetAllNotifications() { List <NotificationDto> notificationList = new List <NotificationDto>(); List <Notification> notifications = (from p in _context.Notification select p).ToList(); foreach (Notification notification in notifications) { NotificationDto notificationDto = CreateNotificationDto(notification); notificationList.Add(notificationDto); } return(notificationList); }
public IEnumerable <NotificationDto> getNotificationByProjectId(string projectId) { List <NotificationDto> notificationList = new List <NotificationDto>(); int myProjectId = (from p in _context.Project where p.ProjectSapId == projectId select p.Id).FirstOrDefault(); List <Notification> notifications = (from p in _context.Notification where p.ProjectId == myProjectId select p).ToList(); foreach (Notification notification in notifications) { NotificationDto notificationDto = CreateNotificationDto(notification); notificationList.Add(notificationDto); } return(notificationList); }
public IEnumerable <NotificationDto> GetDepartementalNotifications(string departmentId) { if (departmentId.Substring(0, 3) == "All") { return(GetAllNotifications()); } else { List <NotificationDto> notificationList = new List <NotificationDto>(); string id = departmentId.Substring(0, 3); List <Notification> notifications = (from p in _context.Notification where p.Department == id select p).ToList(); foreach (Notification notification in notifications) { NotificationDto notificationDto = CreateNotificationDto(notification); notificationList.Add(notificationDto); } return(notificationList); } }