예제 #1
0
        public ActionResult SaveOrUpdate(Customer customer)
        {
            try
            {
                if (customer.Id > 0)
                {
                    customer = this.CustomerRepository.Get(customer.Id);

                    TryUpdateModel(customer);
                }

                if (customer.Pinyin.IsNullOrEmpty() && !customer.Name.IsNullOrEmpty())
                {
                    customer.Pinyin = ChineseToSpell.GetChineseSpell(customer.Name);
                }

                customer = this.CustomerRepository.SaveOrUpdate(customer);

                return JsonSuccess(customer);

            }
            catch (Exception ex)
            {
                return JsonError(ex.Message);
            }
        }
예제 #2
0
        public ActionResult Edit(int? id)
        {
            Customer item = null;

            if (id.HasValue)
            {
                item = this.CustomerRepository.Get(id.Value);
            }

            if (item == null)
            {
                item = new Customer();
            }

            return View(item);
        }
예제 #3
0
 public static CustomerModel From(Customer customer)
 {
     return new CustomerModel(customer);
 }
예제 #4
0
        public CustomerModel(Customer customer)
            : base(customer)
        {
            if (customer.CustomerType != null)
            {
                this.CustomerTypeId = customer.CustomerType.Id;
                this.CustomerTypeString = customer.CustomerType.Name;
            }

            if (customer.CustomerGrade != null)
            {
                this.CustomerGradeId = customer.CustomerGrade.Id;
                this.CustomerGradeString = customer.CustomerGrade.Name;
            }

            this.ShoukuanQc = customer.ShoukuanQc;
            this.ShoukuanYing = customer.ShoukuanYing;
            this.ShoukuanYu = customer.ShoukuanYu;
            this.AllowDebt = customer.AllowDebt.ToString();
            this.Debt = customer.Debt;
            this.Point = customer.Point;
        }