public List <Notification> GetAllNotification(NotificationDateRangeSC notification) { var result = new List <Notification>(); try { var query = Context.Notification .Include(n => n.ToUserNavigation) .Include(n => n.Group) .Where(n => n.IsDeleted == false) .AsQueryable(); if (notification != null) { if (notification.ToUser != 0) { query = query.Where(r => r.ToUser == notification.ToUser); } if (notification.BookingDateFrom.HasValue && notification.BookingDateFrom.Value != DateTime.MinValue) { query = query.Where(r => r.CreateDate >= notification.BookingDateFrom); } if (notification.BookingDateTo.HasValue && notification.BookingDateTo.Value != DateTime.MinValue) { query = query.Where(r => r.CreateDate <= notification.BookingDateTo); } result = query.ToList(); } } catch { } return(result); }
public PartialViewResult AllNotification(NotificationDateRangeSC reservation) { reservation.ToUser = LoggedUserId; var notifications = UnitOfWork.NotificationBL.GetAllNotification(reservation).Select(n => new NotificationDto(n)).OrderByDescending(c => c.Date).ToList(); return(PartialView(notifications)); }