public async Task <int> GetTotalNumberOfComments(Guid notificationId, NotificationShipmentsCommentsType type)
        {
            if (type == NotificationShipmentsCommentsType.Shipments)
            {
                return(await context.NotificationComments.CountAsync(p => p.NotificationId == notificationId& p.ShipmentNumber > 0));
            }

            return(await context.NotificationComments.CountAsync(p => p.NotificationId == notificationId && p.ShipmentNumber == 0));
        }
 public GetImportNotificationComments(Guid notificationId, NotificationShipmentsCommentsType type, int pageNumber, DateTime?startDate, DateTime?endDate, int?shipmentNumber, string userId)
 {
     this.NotificationId = notificationId;
     this.Type           = type;
     this.PageNumber     = pageNumber;
     this.StartDate      = startDate == null ? DateTime.MinValue : startDate.GetValueOrDefault();
     this.EndDate        = endDate == null ? DateTime.MaxValue : endDate.GetValueOrDefault();
     this.ShipmentNumber = shipmentNumber.GetValueOrDefault();
     this.UserId         = userId;
 }
Beispiel #3
0
        public async Task <ActionResult> Delete(Guid id, Guid commentId, NotificationShipmentsCommentsType type, string filter, int page = 1)
        {
            DateTime startDate      = new DateTime();
            DateTime endDate        = new DateTime();
            int?     shipmentNumber = null;
            string   user           = string.Empty;

            GetFilteredTempData(filter, out startDate, out endDate, out shipmentNumber, out user);

            var comments = await this.mediator.SendAsync(new GetNotificationComments(id, type, page, startDate, endDate, shipmentNumber, user));

            DeleteCommentViewModel model = new DeleteCommentViewModel()
            {
                NotificationId = id,
                CommentId      = commentId,
                Comment        = comments.NotificationComments.FirstOrDefault(p => p.CommentId == commentId),
                Type           = type,
                Page           = page
            };

            return(View(model));
        }
Beispiel #4
0
        public async Task <ActionResult> Index(Guid id, string filter, NotificationShipmentsCommentsType type = NotificationShipmentsCommentsType.Notification, int page = 1)
        {
            DateTime startDate      = new DateTime();
            DateTime endDate        = new DateTime();
            int?     shipmentNumber = null;
            string   user           = string.Empty;

            GetFilteredTempData(filter, out startDate, out endDate, out shipmentNumber, out user);

            var comments = await this.mediator.SendAsync(new GetNotificationComments(id, type, page, startDate, endDate, shipmentNumber, user));

            var users = await this.mediator.SendAsync(new GetNotificationCommentsUsers(id, type));

            CommentsViewModel model = new CommentsViewModel
            {
                NotificationId                = id,
                Type                          = type,
                SelectedFilter                = filter,
                TotalNumberOfComments         = comments.NumberOfComments,
                ShipmentNumberStr             = shipmentNumber.ToString(),
                PageNumber                    = comments.PageNumber,
                PageSize                      = comments.PageSize,
                TotalNumberOfFilteredComments = comments.NumberOfFilteredComments,
                Comments                      = comments.NotificationComments.OrderByDescending(p => p.ShipmentNumber).ThenByDescending(p => p.DateAdded).ToList(),
                SelectedUser                  = user
            };

            foreach (KeyValuePair <string, string> u in users.Users)
            {
                model.Users.Add(u.Key, u.Value);
            }

            model.SetDates(startDate, endDate);

            return(View(model));
        }
 public GetImportNotificationCommentsUsers(Guid notificationId, NotificationShipmentsCommentsType type)
 {
     this.NotificationId = notificationId;
     this.Type           = type;
 }
        public async Task <List <string> > GetUsers(Guid notificationId, NotificationShipmentsCommentsType type)
        {
            var allComments = await this.GetCommentsByType(notificationId, type);

            return(allComments.Select(p => p.UserId).Distinct().ToList());
        }
        public async Task <List <NotificationComment> > GetPagedComments(Guid notificationId, NotificationShipmentsCommentsType type, int pageNumber, int pageSize, DateTime startDate, DateTime endDate, int shipmentNumber, string user)
        {
            var allCommentsForType = await this.GetCommentsByType(notificationId, type);

            DateTime endDateForQuery = endDate == DateTime.MaxValue ? endDate : endDate.AddDays(1);

            var returnComments = allCommentsForType.Where(p => p.DateAdded >= startDate && p.DateAdded < endDateForQuery);

            if (shipmentNumber != default(int))
            {
                returnComments = returnComments.Where(p => p.ShipmentNumber == shipmentNumber);
            }

            if (user != null)
            {
                returnComments = returnComments.Where(p => p.UserId == user);
            }

            return(returnComments
                   .OrderByDescending(x => x.ShipmentNumber)
                   .ThenByDescending(x => x.DateAdded)
                   .Skip((pageNumber - 1) * pageSize)
                   .Take(pageSize)
                   .ToList());
        }
        public async Task <List <NotificationComment> > GetComments(Guid notificationId, NotificationShipmentsCommentsType type, DateTime startDate, DateTime endDate, int shipmentNumber, string user)
        {
            var allCommentsForType = await this.GetCommentsByType(notificationId, type);

            DateTime endDateForQuery = endDate == DateTime.MaxValue ? endDate : endDate.AddDays(1);

            if (shipmentNumber != default(int))
            {
                return(allCommentsForType.Where(p => p.DateAdded >= startDate && p.DateAdded < endDateForQuery && p.ShipmentNumber == shipmentNumber).ToList());
            }

            if (user != null)
            {
                return(allCommentsForType.Where(p => p.DateAdded >= startDate && p.DateAdded < endDateForQuery && p.UserId == user).ToList());
            }

            return(allCommentsForType.Where(p => p.DateAdded >= startDate && p.DateAdded < endDateForQuery).ToList());
        }
 private async Task <IEnumerable <NotificationComment> > GetCommentsByType(Guid notificationId, NotificationShipmentsCommentsType type)
 {
     if (type == NotificationShipmentsCommentsType.Notification)
     {
         return(await context.NotificationComments.Where(p => p.NotificationId == notificationId && p.ShipmentNumber == 0).ToListAsync());
     }
     return(await context.NotificationComments.Where(p => p.NotificationId == notificationId && p.ShipmentNumber != 0).ToListAsync());
 }
        public async Task <int> GetTotalNumberOfComments(Guid notificationId, NotificationShipmentsCommentsType type)
        {
            var allCommentsForType = await this.GetCommentsByType(notificationId, type);

            return(allCommentsForType.Count());
        }