public ActionResult Create() { var model = new HotelCreateModel() { Boss = new BossCreateModel() }; return View(model); }
public ActionResult Create(HotelCreateModel model) { bool allEmpty = string.IsNullOrEmpty(model.Boss?.FirstName) && string.IsNullOrEmpty(model.Boss?.SecondName) && string.IsNullOrEmpty(model.Boss?.MiddleName) && string.IsNullOrEmpty(model.Boss?.IndividualId); bool allFilled = !string.IsNullOrEmpty(model.Boss?.FirstName) && !string.IsNullOrEmpty(model.Boss.SecondName) && !string.IsNullOrEmpty(model.Boss.MiddleName) && !string.IsNullOrEmpty(model.Boss.IndividualId); if (!allEmpty && !allFilled) return View(model); if (ModelState.IsValid) { var hotel = _hotelCreateCommand.Execute(model); return RedirectToAction("Details", new {id = hotel.Id}); } return View(model); }