示例#1
0
        public ActionResult Create(GarageDTO garage)
        {
            if (garage.TyreHotel && garage.TyreSlots == null)
            {
                ModelState.AddModelError(nameof(GarageDTO.TyreSlots), "Should be filled");
            }

            if (ModelState.IsValid)
            {
                garageRepository.Insert(GarageAssembler.Create(garage));
                return(RedirectToAction("Index"));
            }

            return(View(garage));
        }
示例#2
0
        public ActionResult Edit(GarageDTO garageDTO)
        {
            if (garageDTO.TyreHotel && garageDTO.TyreSlots == null)
            {
                ModelState.AddModelError(nameof(GarageDTO.TyreSlots), "Should be filled");
            }

            if (ModelState.IsValid)
            {
                var garage = garageRepository.FindById(garageDTO.Id);
                garageRepository.Update(GarageAssembler.Update(garage, garageDTO));
                return(RedirectToAction("Index"));
            }

            return(View(garageDTO));
        }