예제 #1
0
        public CustomerProfileModel CustomerProfile(int CustId)
        {
            using (var db = new EntityContext())
            {
                TbCustomer          customer            = customerUtility.GetCustomerById(db, CustId);
                CustomerSingleModel customerModelSource = customerUtility.CustomerSingleModelProperty(customer);
                List <TbItems>      items = db.TbItems
                                            .Include(i => i.Customer)
                                            .Include(i => i.Status)
                                            .Where(i => i.Customer.Id == CustId).ToList();
                List <ItemSingleModel> itemsModelSource = new List <ItemSingleModel>();
                if (items != null)
                {
                    itemsModelSource = itemsUtility.AssingItemsProperty(items);
                }
                ;

                CustomerProfileModel profile = new CustomerProfileModel
                {
                    customerModel = customerModelSource,
                    itemsModel    = itemsModelSource
                };
                return(profile);
            }
        }
예제 #2
0
 public bool Create(CustomerSingleModel model)
 {
     using (var db = new EntityContext())
     {
         if (!CheckDuplicateNumber(model.Phonenumber))
         {
             TbCustomer customer = new TbCustomer
             {
                 Phonenumber = model.Phonenumber,
                 Name        = model.Name,
                 Password    = model.Password,
                 Address     = model.Address,
                 BCEL_Baht   = model.BCEL_Baht,
                 BCEL_Dollar = model.BCEL_Dollar,
                 BCEL_Kip    = model.BCEL_Kip,
                 Status      = db.tbStatuses.FirstOrDefault(s => s.Id == 1),
                 isDeleted   = false
             };
             db.tbCustomers.Add(customer);
             db.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
예제 #3
0
 public bool Register(ProfileModel model)
 {
     using (var db = new EntityContext())
     {
         if (!_customer.CheckExistingPhonenumber(db, model.Phonenumber, 0))
         {
             TbCustomer customer = new TbCustomer
             {
                 Name        = model.Name,
                 Status      = db.tbStatuses.FirstOrDefault(s => s.Id == 1),
                 Address     = model.Address,
                 BCEL_Baht   = model.BCEL_Baht,
                 BCEL_Dollar = model.BCEL_Dollar,
                 BCEL_Kip    = model.BCEL_Kip,
                 Phonenumber = model.Phonenumber,
                 isDeleted   = false,
                 Password    = model.Password
             };
             db.tbCustomers.Add(customer);
             db.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
예제 #4
0
 public CustomerSingleModel CustomerSingleModelProperty(TbCustomer customer)
 {
     return(new CustomerSingleModel
     {
         Id = customer.Id,
         Address = customer.Address,
         BCEL_Baht = customer.BCEL_Baht,
         BCEL_Dollar = customer.BCEL_Dollar,
         BCEL_Kip = customer.BCEL_Kip,
         Phonenumber = customer.Phonenumber,
         Status = customer.Status.Status,
         Password = customer.Password,
         isDeleted = customer.isDeleted
     });
 }
예제 #5
0
 public ProfileModel AssignCustomerProfile(TbCustomer customer)
 {
     return(new ProfileModel
     {
         Id = customer.Id,
         Name = customer.Name,
         Address = customer.Address,
         BCEL_Baht = customer.BCEL_Baht,
         BCEL_Dollar = customer.BCEL_Dollar,
         BCEL_Kip = customer.BCEL_Kip,
         Status = customer.Status.Status,
         Phonenumber = customer.Phonenumber,
         Password = customer.Password
     });
 }
        private TbCustomer buildDbEntity(Customer entity)
        {
            TbCustomer value = Mapper.Map <TbCustomer>(entity);

            return(value);
        }