示例#1
0
        public bool Update(Customer customer)
        {
            var cust = _customers.SingleOrDefault(x => x.CustomerId == customer.CustomerId);
            if (cust == null) return false;

            _customers.Remove(cust);
            _customers.Add(customer);
            return true;
        }
示例#2
0
        private bool Update(ControllerContext context, Customer customer)
        {
            var result = _repository.Update(customer);

            //ユーザに対するメッセージを追加
            var msg = result ? "Sucsessfully updated." : "Update failed.";
            context.Controller.TempData["OutputMessage"] = msg;
            return result;
        }
示例#3
0
 private bool Validate(ControllerContext context, Customer customer)
 {
     var result = true;
     var modelState = context.Controller.ViewData.ModelState;
     if (string.IsNullOrEmpty(customer.Country))
     {
         modelState.AddModelError("Country", "Need input");
         //モデルの状態をTempDataに保存
         context.Controller.TempData["ModelState"] = modelState;
         result = false;
     }
     return result;
 }
 public ActionResult Update(Customer customer)
 {
     var model = _service.TryUpdateCustomer(ControllerContext, customer);
     return RedirectToAction("edit", new { id = customer.CustomerId });
 }
示例#5
0
 public EditCustomerViewModel TryUpdateCustomer(ControllerContext controllerContext, Customer customer)
 {
     if (Validate(controllerContext, customer)) Update(controllerContext, customer);
     return EditCustomer(customer.CustomerId);
 }