示例#1
0
 public List <ItemSingleModel> GetAll()
 {
     using (var db = new EntityContext())
     {
         var items = itemsUtility.GetAllItem(db).ToList();    //Get data from database
         var model = itemsUtility.AssingItemsProperty(items); //post data to model
         return(model);
     }
 }
        public List <CustomerItemModel> GetCustomerList()
        {
            using (var db = new EntityContext())
            {
                var customers = customerUtility.GetAllCustomer(db);

                List <CustomerItemModel> model = new List <CustomerItemModel>();
                foreach (var customer in customers)
                {
                    CustomerItemModel ci = new CustomerItemModel();
                    ci.CustomerId              = customer.Id;
                    ci.CustomerName            = customer.Name;
                    ci.CountItems              = itemsUtility.GetAllItem(db).Count(i => i.Customer.Id == customer.Id);
                    ci.CountItemsToPickup      = itemsUtility.GetAllItem(db).Count(i => i.Customer.Id == customer.Id && i.Status.Id == 2);
                    ci.CountItemsPickedUp      = itemsUtility.GetAllItem(db).Count(i => i.Customer.Id == customer.Id && i.Status.Id == 3);
                    ci.CountItemsInProcess     = itemsUtility.GetAllItem(db).Count(i => i.Customer.Id == customer.Id && i.Status.Id == 4);
                    ci.CountItemsToSend        = itemsUtility.GetAllItem(db).Count(i => i.Customer.Id == customer.Id && i.Status.Id == 5);
                    ci.CountItemsAlreadySend   = itemsUtility.GetAllItem(db).Count(i => i.Customer.Id == customer.Id && i.Status.Id == 6);
                    ci.CountItemsCannotContact = itemsUtility.GetAllItem(db).Count(i => i.Customer.Id == customer.Id && i.Status.Id == 7);
                    model.Add(ci);
                }
                return(model.ToList());
            }
        }
 public ConsolidatedItemsModel GetItems(int consolidatedId)
 {
     using (var db = new EntityContext())
     {
         var source = db.tbConsolidateLists
                      .Include(x => x.Customer)
                      .FirstOrDefault(x => x.Id == consolidatedId);
         var itemsource = _itemUtility.GetAllItem(db).Where(x => db.tbConsolidatedItems.Where(c => c.Consolidator.Id == consolidatedId).Select(c => c.Items.Id).Contains(x.Id)).ToList();
         ConsolidatedItemsModel model = new ConsolidatedItemsModel
         {
             ConsolidationId     = source.Id,
             ConsolidationNumber = source.ConsolidateNumber,
             Customername        = source.Customer.Name,
             CustomerPhonenumber = source.Customer.Phonenumber,
             Items = _itemUtility.AssingItemsProperty(itemsource)
         };
         return(model);
     }
 }