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); } }
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); }
public static CustomerModel From(Customer customer) { return new CustomerModel(customer); }
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; }