Example #1
0
 public List <CustomerSingleModel> GetAll()
 {
     using (var db = new EntityContext())
     {
         var customerList = customerUtility.GetAllCustomer(db);
         if (customerList != null)
         {
             List <CustomerSingleModel> customerModel = customerList.Select(r => new CustomerSingleModel
             {
                 Id          = r.Id,
                 Status      = r.Status.Status,
                 Address     = r.Address,
                 BCEL_Baht   = r.BCEL_Baht,
                 BCEL_Dollar = r.BCEL_Dollar,
                 BCEL_Kip    = r.BCEL_Kip,
                 isDeleted   = r.isDeleted,
                 Password    = r.Password,
                 Phonenumber = r.Phonenumber
             }).ToList();
             return(customerModel);
         }
         else
         {
             return(new List <CustomerSingleModel>());
         }
     }
 }
        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());
            }
        }