Example #1
0
        public ActionResult Create(EditManagerItem item)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var managerItem = new ModelLayer.Manager() { ManagerName = item.ManagerName };

                    _managerRepository.InsertOrUpdate(managerItem);
                    _managerRepository.SaveChanges();

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

            var editManagerItem = new EditManagerItem()
            {
                Id = managerItem.Id,
                ManagerName = managerItem.ManagerName
            };

            if (Request.IsAjaxRequest())
            {
                return PartialView("_EditPartial", editManagerItem);
            }
            return View("Edit", editManagerItem);
        }
Example #3
0
        public ActionResult Edit(EditManagerItem item)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var managerItem = _managerRepository.GetById(item.Id);

                    managerItem.ManagerName = item.ManagerName;

                    _managerRepository.InsertOrUpdate(managerItem);
                    _managerRepository.SaveChanges();

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