Exemple #1
0
        public bool Update(TypeOfHousingEditViewModel typeOfHousingVM)
        {
            var typeOfHousing = typeOfHousingRep.GetByName(typeOfHousingVM.Name);

            if (typeOfHousing != null && typeOfHousing.Id != typeOfHousingVM.Id)
            {
                return(false);
            }

            var update = typeOfHousingRep.GetById(typeOfHousingVM.Id);

            update.Name = typeOfHousingVM.Name;
            typeOfHousingRep.SaveChanges();
            return(true);
        }
        public ActionResult Edit(TypeOfHousingEditViewModel typeOfHousingVM)
        {
            if (ModelState.IsValid)
            {
                var editConfirm = typeOfHousingService.Update(typeOfHousingVM);

                if (!editConfirm)
                {
                    ModelState.AddModelError("Name", "Name alreadt exists");
                    return(View(typeOfHousingVM));
                }

                return(RedirectToAction("Index"));
            }

            return(View(typeOfHousingVM));
        }