Exemplo n.º 1
0
        public ActionResult EditForm(int? id)
        {
            var obj = new CustomerItem();

            var listProductType = customerRepository.GetListForTree<object>();

            if (id.HasValue)
                obj = customerRepository.GetItemById<CustomerItem>(id.Value);

            return Json(new
            {
                data = obj,
                listType = listProductType
            }, JsonRequestBehavior.AllowGet);
        }
Exemplo n.º 2
0
        public void UpdateCustomer(CustomerItem customer)
        {
            var cus = web365db.tblCustomer.FirstOrDefault(c => c.ID == customer.ID);

            cus.Password = string.IsNullOrEmpty(customer.Password) ? cus.Password : Web365Utility.Web365Utility.MD5Hash(customer.Password);

            cus.LastName = customer.LastName;

            cus.Email = customer.Email;

            cus.Phone = customer.Phone;

            cus.Address = customer.Address;

            web365db.Entry(cus).State = EntityState.Modified;

            web365db.SaveChanges();
        }
Exemplo n.º 3
0
        public bool TryGetById(out CustomerItem customer, int id)
        {
            customer = web365db.tblCustomer.Where(c => c.ID == id).Select(c => new CustomerItem()
            {
                ID = c.ID,
                UserName = c.UserName,
                FirstName = c.FirstName,
                LastName = c.LastName,
                Email = c.Email,
                Phone = c.Phone,
                Address = c.Address
            }).FirstOrDefault();

            return customer != null;
        }
Exemplo n.º 4
0
        public bool TryGetByUserNameAndPassword(out CustomerItem customer, string userName, string password)
        {
            password = Web365Utility.Web365Utility.MD5Hash(password);

            customer = web365db.tblCustomer.Where(c => c.UserName == userName && c.Password == password).Select(c => new CustomerItem()
            {
                ID = c.ID,
                UserName = c.UserName,
                FirstName = c.FirstName,
                LastName = c.LastName,
                Email = c.Email,
                Phone = c.Phone,
                Address = c.Address,
                IsActive = c.IsActive.HasValue && c.IsActive.Value
            }).FirstOrDefault();

            return customer != null;
        }