Exemplo n.º 1
0
 public TbCustomer Login(string phonenumber, string password)
 {
     using (var db = new EntityContext())
     {
         var source = _customer.GetAll(db).Where(c => c.Phonenumber == phonenumber && c.Password == password).FirstOrDefault();
         return(source);
     }
 }
Exemplo n.º 2
0
        public List <ItemHistoryModel> GetItemHistory(DateTime?fromDate, DateTime?toDate)
        {
            using (var db = new EntityContext())
            {
                var customers = _customer.GetAll(db).ToList();
                List <ItemHistoryModel> model = new List <ItemHistoryModel>();
                if (customers == null)
                {
                    return(new List <ItemHistoryModel>());
                }
                ;
                if (fromDate == null && toDate == null)
                {
                    foreach (var customer in customers)
                    {
                        ItemHistoryModel history = new ItemHistoryModel
                        {
                            CustomerId    = customer.Id,
                            TotalItemSent = _item.GetAll(db)
                                            .Where(i => i.Customer.Id == customer.Id &&
                                                   i.Status.Id == 6
                                                   ).Count(),
                            TotalItemInProcess = _item.GetAll(db)
                                                 .Where(i => i.Customer.Id == customer.Id &&
                                                        (i.Status.Id == 3 || i.Status.Id == 4 || i.Status.Id == 5 || i.Status.Id == 7 || i.Status.Id == 9)
                                                        ).Count(),
                            TotalItemReceive = _item.GetAll(db)
                                               .Where(i => i.Customer.Id == customer.Id
                                                      ).Count(),
                            TotalItemReturn = _item.GetAll(db)
                                              .Where(i => i.Customer.Id == customer.Id &&
                                                     i.Status.Id == 8
                                                     ).Count()
                        };
                        model.Add(history);
                    }
                }
                else
                {
                    foreach (var customer in customers)
                    {
                        ItemHistoryModel history = new ItemHistoryModel
                        {
                            CustomerId    = customer.Id,
                            TotalItemSent = _item.GetAll(db)
                                            .Where(i => i.Customer.Id == customer.Id &&
                                                   i.Status.Id == 6 &&
                                                   i.ReceiveDate >= fromDate && i.ReceiveDate <= toDate).Count(),
                            TotalItemInProcess = _item.GetAll(db)
                                                 .Where(i => i.Customer.Id == customer.Id &&
                                                        (i.Status.Id == 3 || i.Status.Id == 4 || i.Status.Id == 5 || i.Status.Id == 7 || i.Status.Id == 9) &&
                                                        i.ReceiveDate >= fromDate && i.ReceiveDate <= toDate).Count(),
                            TotalItemReceive = _item.GetAll(db)
                                               .Where(i => i.Customer.Id == customer.Id &&
                                                      i.ReceiveDate >= fromDate && i.ReceiveDate <= toDate).Count(),
                            TotalItemReturn = _item.GetAll(db)
                                              .Where(i => i.Customer.Id == customer.Id &&
                                                     i.Status.Id == 8 &&
                                                     i.ReceiveDate >= fromDate && i.ReceiveDate <= toDate).Count()
                        };
                        model.Add(history);
                    }
                }

                return(model);
            }
        }