Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void GetPaginatedNotifications(NotificationVM notify, int EmpId)
- {
- List<NotifierSummaryDto> notifierSummaries = new List<NotifierSummaryDto>();
- var Today = DateTime.Now.Date;
- var Query = (from n in notifyDb.NotificationMasters.Where(x=>x.CompanyId==companyId)
- join nt in notifyDb.NotificationTypes on n.NotificationTypeId equals nt.Id
- // join empN in notifyDb.ApplicationNotifications.Where(x => x.EmployeeId == EmpId && x.IsSeen==0) on n.NotificationId equals empN.NotificationId into emm from emn1 in emm.DefaultIfEmpty()
- where n.AppDisplay == 1
- select new NotifierSummaryDto
- {
- IsJsonData=n.IsTextNotifyJsonFormatted,
- IsAppDisplay = n.AppDisplay == 0 ? "No" : "Yes",
- IsEmpSpecific = n.EmpSpecific == 0 ? "No" : "Yes",
- EntryBy = n.EntryBy,
- TextNotify = n.TextNotify,
- EmailBody = n.EmailBody,
- IsModuleSpecific = n.ModuleSpecific == 0 ? "No" : "Yes",
- NotificationId = n.NotificationId,
- AppDisplay = n.AppDisplay,
- EmpSpecific = n.EmpSpecific,
- ModuleSpecific = n.ModuleSpecific,
- ModuleId = n.ModuleId,
- SubModuleId = n.SubModuleId,
- FeatureId = n.FeatureId,
- ApplicationImmediate = notifyDb.ApplicationNotifications.Where(x => x.NotificationId == n.NotificationId).Select(x => x.Immediate).FirstOrDefault(),
- AppNotifyDisplayEnd = notifyDb.ApplicationNotifications.Where(x => x.NotificationId == n.NotificationId).Select(x => x.DisplayEnd).FirstOrDefault(),
- AppNotifyDisplayStart = notifyDb.ApplicationNotifications.Where(x => x.NotificationId == n.NotificationId).Select(x => x.DisplayStart).FirstOrDefault(),
- EmpId = notifyDb.ApplicationNotifications.Where(x => x.NotificationId == n.NotificationId && x.EmployeeId == EmpId).Select(x => x.EmployeeId).FirstOrDefault(),
- EntryDate = n.EntryDate,
- IsSeen = notifyDb.EmployeeNotificationVisibilityStatus.Where(x => x.NotificationId == n.NotificationId).Select(x => x.IsSeen).FirstOrDefault()
- }).Where(x => x.IsSeen != 1).Where(x => (x.EmpSpecific == 1 && x.EmpId == EmpId) || (x.EmpSpecific == 0)).OrderByDescending(x => x.NotificationId);
- var pager = new Pager(Query.Count(), notify.page, notify.ItemPerPage);
- notify.SummaryList = Query.Skip((pager.CurrentPage - 1) * pager.PageSize).Take(pager.PageSize).ToList();
- notify.pager = pager;
- foreach (var item in notify.SummaryList)
- {
- if (item.EmpSpecific == 1)
- {
- if (item.EmpId != EmpId)
- continue;
- }
- if (item.CompanyId != null)
- {
- if (item.CompanyId != companyId)
- {
- continue;
- }
- }
- item.EmpId = EmpId;
- if (item.IsJsonData == 1)
- {
- item.NotificationText = DesirializeString(item.TextNotify);
- }
- if (item.ApplicationImmediate != -1)
- {
- if (item.ApplicationImmediate == 1)
- {
- item.NotificationServiceTime = CalculateLengthOfNotificationService(item.EntryDate);
- notifierSummaries.Add(item);
- }
- else
- {
- if (item.AppNotifyDisplayStart <= Today && item.AppNotifyDisplayEnd >= Today)
- {
- item.NotificationServiceTime = CalculateLengthOfNotificationService(item.AppNotifyDisplayStart);
- notifierSummaries.Add(item);
- }
- }
- }
- else
- {
- item.NotificationServiceTime = CalculateLengthOfNotificationService(item.EntryDate);
- notifierSummaries.Add(item);
- }
- }
- notify.SummaryList = notifierSummaries;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement