Пример #1
0
        public NotificationsDTO GetNotificationsForUser(Guid userId)
        {
            var notifications = new NotificationsDTO();

            notifications.Smses = _context.SmsesToSend
                                  .Where(s => s.UserId == userId)
                                  .Select(s => new NotificationsDTO.Sms
            {
                CreationTime = s.CreationTime,
                Message      = s.Message,
                HasBeenSent  = s.HasBeenSent
            })
                                  .OrderByDescending(a => a.CreationTime)
                                  .ToList();

            notifications.Emails = _context.MailsToSend
                                   .Where(e => e.UserId == userId)
                                   .Select(e => new NotificationsDTO.Email
            {
                CreationTime = e.CreationTime,
                Subject      = e.Subject,
                Content      = e.Content,
                From         = e.EmailFrom,
                HasBeenSent  = e.HasBeenSent
            })
                                   .OrderByDescending(a => a.CreationTime)
                                   .ToList();

            return(notifications);
        }
Пример #2
0
        public IEnumerable <NotificationsDTO> GetBarrilModelsAgrupados()
        {
            int[] EstadoPosible = { 1, 2 };
            IList <NotificationsDTO> newList = new List <NotificationsDTO>();
            NotificationsDTO         item    = null;
            var FechaLimite = DateTime.Now.AddDays(2);
            /////Traer Pedidos demorados
            var result = (from b in db.PedidoModels
                          where (b.fechaPactada <= FechaLimite) && (EstadoPosible.Equals(b.Estado))
                          select b);

            if (result.Count() > 0)
            {
                item = new NotificationsDTO()
                {
                    Message = String.Format("Hay {0} Pedidos a Punto de Vencer", result.Count()), LinkToDirect = "Pedido", count = result.Count()
                };
                newList.Add(item);
            }

            ///check if there are barriles without comeback
            ///
            var resultBarriles = (from b in db.BarrilModels
                                  join x in db.MovimientosModels on b.idEntrega.Value equals x.idEntrega
                                  where (x.fechaPactada >= FechaLimite) && (EstadoPosible.Equals(x.Estado))
                                  select b);

            if (resultBarriles.Count() > 0)
            {
                item = new NotificationsDTO()
                {
                    Message = String.Format("Hay {0} Barriles que no han sido devueltos", resultBarriles.Count()), LinkToDirect = "Barriles", count = resultBarriles.Count()
                };
                newList.Add(item);
            }



            return(newList);
        }