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); }
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); }
public Order GetOrder(Guid key) { var order = _orderRepository.AllIncluding(x => x.Customer) .FirstOrDefault(x => x.Key == key); return(order); }
// 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); }
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); }
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)); }
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)); }
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); }
//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); }
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)); } }
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 })); }
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)); }
// 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)); }
public Affiliate GetAffiliate(Guid key) { var affiliate = _affiliateRepository.AllIncluding(x => x.User).FirstOrDefault(x => x.Key == key); return(affiliate); }