Ejemplo n.º 1
0
        public async Task <PaginatedList <SaleDTO> > GetSales(int pageIndex, int pageSize, int?officeId, string search)
        {
            string searchParam = search == null ? string.Empty : search;
            Expression <Func <Sale, object> > groupIncluding   = c => c.Group;
            Expression <Func <Sale, object> > managerIncluding = c => c.User;
            PaginatedList <Sale> sales = null;

            if (officeId != null)
            {
                sales = await salesRepository
                        .AllIncluding(groupIncluding, managerIncluding)
                        .Where(_ => _.GroupId == officeId)
                        .Where(_ => _.Name.Contains(searchParam) || _.Group.Name.Contains(searchParam) || _.User.Email.Contains(searchParam))
                        .ToPaginatedList(pageIndex, pageSize, _ => _.Name);
            }
            else
            {
                sales = await salesRepository
                        .AllIncluding(groupIncluding, managerIncluding)
                        .Where(_ => _.Name.Contains(searchParam) || _.Group.Name.Contains(searchParam) || _.User.Email.Contains(searchParam))
                        .ToPaginatedList(pageIndex, pageSize, _ => _.Name);
            }
            var mappedData = mapper.Map <PaginatedList <Sale>, PaginatedList <SaleDTO> >(sales);

            return(mappedData);
        }
Ejemplo n.º 2
0
        public async Task <PaginatedList <UserDTO> > GetUsers(int pageIndex, int pageSize, int?officeId, string search)
        {
            string searchParam = search == null ? string.Empty : search;
            Expression <Func <User, object> > groupIncluding = c => c.Group;
            PaginatedList <User> users = null;

            if (officeId != null)
            {
                users = await userRepository
                        .AllIncluding(groupIncluding)
                        .Where(_ => _.GroupId == officeId)
                        .Where(_ => _.Email.Contains(searchParam) || _.Group.Name.Contains(searchParam) || _.Id.ToString().Contains(searchParam))
                        .ToPaginatedList(pageIndex, pageSize, _ => _.Email);
            }
            else
            {
                users = await userRepository
                        .AllIncluding(groupIncluding)
                        .Where(_ => _.Email.Contains(searchParam) || _.Group.Name.Contains(searchParam) || _.Id.ToString().Contains(searchParam))
                        .ToPaginatedList(pageIndex, pageSize, _ => _.Email);
            }
            var mappedData = mapper.Map <PaginatedList <User>, PaginatedList <UserDTO> >(users);

            return(mappedData);
        }
Ejemplo n.º 3
0
        public Order GetOrder(Guid key)
        {
            var order = _orderRepository.AllIncluding(x => x.Customer)
                        .FirstOrDefault(x => x.Key == key);

            return(order);
        }
Ejemplo n.º 4
0
        // Affiliate

        public PaginatedList <Affiliate> GetAffiliates(int pageIndex, int pageSize)
        {
            var affiliates = _affiliateRepository
                             .AllIncluding(x => x.User).OrderBy(x => x.CreatedOn)
                             .ToPaginatedList(pageIndex, pageSize);

            return(affiliates);
        }
Ejemplo n.º 5
0
        public void Add_Items_To_Order()
        {
            var order = _orderRepository.AllIncluding(x => x.Items)
                        .First();
            var items = new List <Item> {
                new Item {
                    Color = "Green"
                },
                new Item {
                    Color = "Red"
                }
            };

            orderService.AddOrderItems(items, order);
        }
Ejemplo n.º 6
0
        public async Task <PaginatedList <GroupDTO> > GetGroups(int pageIndex, int pageSize, int?groupId, string search)
        {
            string searchParam = search == null ? string.Empty : search;
            Expression <Func <Group, object> > officeIncluding = o => o.Office;
            PaginatedList <Group> groups = null;
            var currentGroup             = await groupRepository.FindBy(_ => _.Id == groupId).FirstOrDefaultAsync();

            if (groupId != null)
            {
                groups = await groupRepository
                         .FindBy(_ => _.OfficeId == currentGroup.OfficeId)
                         .Where(_ => _.Name.Contains(searchParam) || _.Id.ToString().Contains(searchParam))
                         .Include(_ => _.Office).ToPaginatedList(pageIndex, pageSize, _ => _.Name);
            }
            else
            {
                groups = await groupRepository
                         .AllIncluding(_ => _.Office)
                         .Where(_ => _.Name.Contains(searchParam) || _.Id.ToString().Contains(searchParam))
                         .ToPaginatedList(pageIndex, pageSize, _ => _.Name);
            }
            var result = mapper.Map <PaginatedList <Group>, PaginatedList <GroupDTO> >(groups);

            return(result);
        }
 public static IQueryable <Shipment> GetShipmentsByAffiliateKey(
     this IEntityRepository <Shipment> shipmentRepository, Guid affiliateKey)
 {
     return(shipmentRepository.AllIncluding(x =>
                                            x.ShipmentType, x => x.ShipmentStates).Where(x =>
                                                                                         x.AffiliateKey == affiliateKey));
 }
Ejemplo n.º 8
0
        public IActionResult UserOders()
        {
            //IEnumerable<Order> orders= repository.FindBy(o => o.UserID == basketService.BasketId);
            var allOders  = repository.AllIncluding(o => o.OrderLines);
            var UserOders = allOders.Where(o => o.UserID == basketService.BasketId);

            return(View(UserOders));
        }
Ejemplo n.º 9
0
        public IActionResult Edit(CreateProductVM model)
        {
            Product productToUpdate = repository
                                      .AllIncluding(p => p.ProductImageMappings, x => x.Category).First(p => p.ID == model.ID);

            productToUpdate.CategoryID  = model.CategoryID;
            productToUpdate.Name        = model.Name;
            productToUpdate.Description = model.Description;
            productToUpdate.Price       = model.Price;

            if (productToUpdate.ProductImageMappings == null)
            {
                productToUpdate.ProductImageMappings =
                    new List <ProductImageMapping>();
            }
            string[] productImages = model.ProductImages
                                     .Where(pi => !string.IsNullOrEmpty(pi)).ToArray();
            for (int i = 0; i < productImages.Length; i++)
            {
                var imageMappingToEdit = productToUpdate.ProductImageMappings
                                         .Where(pim => pim.ImageNumber == i).FirstOrDefault();
                var image = imgRepo.GetSingle(int.Parse(productImages[i]));
                if (imageMappingToEdit == null)
                {
                    productToUpdate.ProductImageMappings.Add(
                        new ProductImageMapping {
                        ProductImage   = image,
                        ProductImageID = image.ID,
                        ImageNumber    = i
                    });
                }
                else
                {
                    if (imageMappingToEdit.ProductImageID !=
                        int.Parse(productImages[i]))
                    {
                        imageMappingToEdit.ProductImage = image;
                    }
                }
            }

            for (int i = productImages.Length;
                 i < Constants.NumberOfProductImages; i++)
            {
                var imageMappingToEdit = productToUpdate
                                         .ProductImageMappings.Where(pim => pim.ImageNumber == i)
                                         .FirstOrDefault();
                if (imageMappingToEdit != null)
                {
                    mapRepo.Delete(imageMappingToEdit);
                }
            }


            repository.Edit(productToUpdate);
            repository.Save();
            return(RedirectToAction(nameof(Index)));
        }
        public static IQueryable <Shipment> GetNotDeliveredShipments(
            this IEntityRepository <Shipment> shipmentRepository)
        {
            var shipmenents = from shipment in shipmentRepository.AllIncluding(
                x => x.ShipmentType, x => x.ShipmentStates)
                              where shipment.ShipmentStates.Any(
                x => x.ShipmentStatus != ShipmentStatus.Delivered)
                              select shipment;

            return(shipmenents);
        }
Ejemplo n.º 11
0
        //This method return empty collection because of saleIncluding is using
        public async Task <PaginatedList <ClientDTO> > GetClients(int pageIndex, int pageSize, int?groupId, string search)
        {
            string searchParam             = search == null ? string.Empty : search;
            PaginatedList <Client> clients = null;
            Expression <Func <Client, object> > saleIncluding = s => s.Sale;

            if (groupId != null)
            {
                clients = await clientRepository.AllIncluding(saleIncluding)
                          .Where(_ => _.Sale.GroupId == groupId)
                          .Where(_ => _.Name.Contains(searchParam))
                          .ToPaginatedList(pageIndex, pageSize, _ => _.Name);
            }
            else
            {
                clients = await clientRepository.AllIncluding(saleIncluding)
                          .Where(_ => _.Name.Contains(searchParam))
                          .ToPaginatedList(pageIndex, pageSize, _ => _.Name);
            }

            var mappedData = mapper.Map <PaginatedList <Client>, PaginatedList <ClientDTO> >(clients);

            return(mappedData);
        }
Ejemplo n.º 12
0
        public IViewComponentResult Invoke(bool nav = false)
        {
            if (nav)
            {
                return(View("NavList", repository.GetAll()));
            }
            else
            {
                IEnumerable <Category> categories = repository
                                                    .AllIncluding(c => c.Products);

                //SelectList x = new SelectList(categories,"ID","Name");

                return(View(categories));
            }
        }
Ejemplo n.º 13
0
        public IActionResult Details(int id, string returnUrl)
        {
            Product product = repository.AllIncluding(
                p => p.ProductImageMappings, x => x.Category).First(p => p.ID == id);

            int[] mappingIds = product.ProductImageMappings
                               .Select(pim => pim.ProductImageID).ToArray();

            List <ProductImage> images = imgRepo
                                         .FindBy(pi => mappingIds.Contains(pi.ID)).ToList();

            return(View(new ProductDetails {
                Product = product,
                ProductImages = images
            }));
        }
Ejemplo n.º 14
0
        public IViewComponentResult Invoke()
        {
            var products = productRepo.AllIncluding(p => p.Category);
            CategoryProductCount vModel = new CategoryProductCount
            {
                CatsWithCount = from m in products
                                where m.CategoryID != null
                                group m by m.Category.Name
                                into catGrop
                                select new CategoryWithCount
                {
                    CategoryName = catGrop.Key,
                    ProductCount = catGrop.Count()
                }
            };

            return(View(vModel));
        }
Ejemplo n.º 15
0
        // Private helpers

        private IQueryable <Shipment> GetInitialShipments()
        {
            return(_shipmentRepository.AllIncluding(x =>
                                                    x.ShipmentType, x => x.ShipmentStates).OrderBy(x => x.CreatedOn));
        }
 public static IQueryable <Order> GetOrdersByCustomer(
     this IEntityRepository <Order> orderRepository, Guid customerKey)
 {
     return(orderRepository.AllIncluding(x =>
                                         x.CustomerKey).Where(x => x.CustomerKey == customerKey));
 }
Ejemplo n.º 17
0
        public Affiliate GetAffiliate(Guid key)
        {
            var affiliate = _affiliateRepository.AllIncluding(x => x.User).FirstOrDefault(x => x.Key == key);

            return(affiliate);
        }