Exemple #1
0
        public ActionResult Create(EditCustomerItem item)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var customerItem = _customerRepository.GetById(item.Id);

                    customerItem.CustomerName = item.CustomerName;

                    _customerRepository.InsertOrUpdate(customerItem);
                    _customerRepository.SaveChanges();

                    return RedirectToAction("Index");
                }
                catch
                {
                    ViewBag.MessageError = "Data error";
                }
            }
            return View();
        }
Exemple #2
0
        public ActionResult Edit(int id)
        {
            var customerItem = _customerRepository.GetById(id);
            if (customerItem == null)
            {
                return View("Error");
            }

            var editCustomerItem = new EditCustomerItem()
            {
                Id = customerItem.Id,
                CustomerName = customerItem.CustomerName
            };

            if (Request.IsAjaxRequest())
            {
                return PartialView("_EditPartial", editCustomerItem);
            }
            return View("Edit", editCustomerItem);
        }
Exemple #3
0
        public ActionResult Edit(EditCustomerItem item)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var customerItem = new ModelLayer.Customer(){ CustomerName = item.CustomerName};

                    _customerRepository.InsertOrUpdate(customerItem);
                    _customerRepository.SaveChanges();

                    return RedirectToAction("Index");
                }
                catch
                {
                    ViewBag.MessageError = "Data error";
                }
            }
            return View();
        }