示例#1
0
        public ActionResult Edit(CustomerModel editedCustomer)
        {
            if (this.ModelState.IsValid)
            {
                var entity = this.UpdateEntity(editedCustomer);
                return this.RedirectToAction("Details", new { entity.Id });
            }

            return this.View(editedCustomer);
        }
示例#2
0
 public ActionResult Delete(CustomerModel entity)
 {
     this.DeleteEntity(entity);
     return this.RedirectToAction("Index");
 }
示例#3
0
 private void DeleteEntity(CustomerModel entity)
 {
     this.entityService.Delete(entity.Id);
 }
示例#4
0
 private Customer UpdateEntity(CustomerModel editedEntity)
 {
     var entity = Mapper.Map<Customer>(editedEntity);
     this.entityService.Update(entity);
     return entity;
 }
示例#5
0
        public ActionResult New(CustomerModel newCustomer)
        {
            if (this.ModelState.IsValid)
            {
                var entity = Mapper.Map<Customer>(newCustomer);
                this.entityService.Add(entity);
                return this.RedirectToAction("Index");
            }

            return this.View(newCustomer);
        }