Esempio n. 1
0
        public ActionResult CreateEdit(Shop model)
        {
            if (ModelState.IsValid)
            {
                if (model.ShopId == 0)
                {
                    _shopRepository.Insert(model);
                }
                else
                {
                    Shop entity = _shopRepository.GetById(model.ShopId);

                    entity.Name = model.Name;
                    entity.Address = model.Address;
                    entity.Mode = model.Mode;

                    _shopRepository.Update(entity);
                }

                _unitOfWork.Save();

                if (model.ShopId > 0)
                {
                    return RedirectToAction("Index");
                }
            }

            return View(model);
        }
Esempio n. 2
0
        public ActionResult CreateEdit(int? id)
        {
            Shop model = null;

            if (!id.HasValue)
            {
                model = new Shop();
                ViewBag.Title = "Create";
            }
            else
            {
                model = _shopRepository.GetById(id);
                ViewBag.Title = "Edit";
            }

            return View(model);
        }