Exemplo n.º 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();
        }
Exemplo n.º 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);
        }
Exemplo n.º 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();
        }