Esempio n. 1
0
        public ActionResult Edit(ChangeTypeView changeTypeModel)
        {
            if (ModelState.IsValid)
            {
                IChangeTypesRepository changeTypesRepository = new ChangeTypesRepository(db);
                ChangeType             changeType            = changeTypesRepository.GetChangeTypeByPK((int)changeTypeModel.ChangeTypePK);
                changeTypeModel.ConvertTo(changeTypeModel, changeType);

                changeTypesRepository.SaveChanges();

                TempData["message"] = LayoutHelper.GetMessage("UPDATE", changeType.ChangeTypePK);

                return(RedirectToAction("Index", "ChangeType"));
            }
            else
            {
                return(View(changeTypeModel));
            }
        }
Esempio n. 2
0
        public ActionResult Add(ChangeTypeView changeTypeView)
        {
            if (ModelState.IsValid)
            {
                IChangeTypesRepository changeTypesRepository = new ChangeTypesRepository(db);
                ChangeType             changeType            = new ChangeType();

                changeTypeView.ConvertTo(changeTypeView, changeType);

                changeTypesRepository.Add(changeType);
                changeTypesRepository.SaveChanges();

                TempData["message"] = LayoutHelper.GetMessage("INSERT", changeType.ChangeTypePK);

                return(RedirectToAction("Index", "ChangeType"));
            }
            else
            {
                return(View(changeTypeView));
            }
        }