public List <ProductArrivalDTO> GetProductArrivals(IncomeCommand command, ref int pagesCount) { IQueryable <ProductArrivalDTO> query; if (command.FilterWorkPlaceId > 0) { query = from c in db.IncomeProducts join income in db.Incomes on c.IncomeId equals income.Id where income.FromWorkPlaceId == command.FilterWorkPlaceId group c by new { c.Product, c.CreatedDate.Value.Date } into grp let SumQuantity = grp.Sum(x => x.Quantity) orderby grp.Key.Date select new ProductArrivalDTO() { ProductCode = grp.Key.Product.Code, ProductName = grp.Key.Product.Name, Date = grp.Key.Date, Quantity = SumQuantity, SupplierName = grp.Key.Product.Supplier.Name }; } else { query = from c in db.IncomeProducts group c by new { c.Product, c.CreatedDate.Value.Date } into grp let SumQuantity = grp.Sum(x => x.Quantity) orderby grp.Key.Date select new ProductArrivalDTO() { ProductCode = grp.Key.Product.Code, ProductName = grp.Key.Product.Name, Date = grp.Key.Date, Quantity = SumQuantity, SupplierName = grp.Key.Product.Supplier.Name }; } if (command.Date != null) { query = from p in query where p.Date.Date >= command.Date.Value.Date && p.Date.Date <= command.Date.Value.Date select p; } if (command.FromDate != null && command.ToDate != null) { query = from p in query where p.Date.Date >= command.FromDate.Value.Date && p.Date.Date <= command.ToDate.Value.Date select p; } pagesCount = (int)Math.Ceiling((double)(from p in query select p).Count() / command.PageSize); query = query.Page(command.PageSize, command.Page); return(query.ToList()); }
public List <IncomeDTO> GetIncomes(IncomeCommand command, ref int pagesCount) { var query = from c in db.Incomes select new IncomeDTO() { Id = c.Id, UserId = c.UserId, UserName = c.User.Name + " " + c.User.Surname, FromWorkplaceId = c.FromWorkPlaceId, FromWorkplaceName = c.FromWorkPlace.Name, ToWorkplaceId = c.ToWorkplaceId, ToWorkplaceName = c.ToWorkPlace.Name, CreatedDate = c.CreatedDate.Value, UpdatedDate = c.UpdatedDate.Value, IsProductStock = c.IsProductStock, IncomeProducts = GetIncomeProducts(c.Id), }; if (command.UserId > 0) { query = from c in query where c.UserId == command.UserId select c; } //if (command.FilterWorkPlaceId > 0) //{ // query = from c in query where c.FromWorkplaceId == command.FilterWorkPlaceId select c; //} if (command.Date != null) { query = from p in query where p.CreatedDate.Date >= command.Date.Value.Date && p.CreatedDate.Date <= command.Date.Value.Date select p; } if (command.FromDate != null && command.ToDate != null) { query = from p in query where p.CreatedDate.Date >= command.FromDate.Value.Date && p.CreatedDate.Date <= command.ToDate.Value.Date select p; } pagesCount = (int)Math.Ceiling((double)(from p in query select p).Count() / command.PageSize); query = query.Page(command.PageSize, command.Page); return(query.ToList()); }
public List <IncomeDTO> GetIncomes(IncomeCommand command, ref int pagesCount) { return(new IncomeDalFacade().GetIncomes(command, ref pagesCount)); }
public List <ProductArrivalDTO> GetProductArrivals(IncomeCommand command, ref int pagesCount) { return(new IncomeDalFacade().GetProductArrivals(command, ref pagesCount)); }