public ActionResult Create(CreateViewModel createViewModel) { if (!ModelState.IsValid) { return View(createViewModel); } var trips = new List<Trip>(); for (var i = 0; i < createViewModel.Table_CheckBox_Trips_Property.Count(); i++) { if (createViewModel.Table_CheckBox_Trips_Property.ToArray()[i].Selected) { trips.Add(TripService.FindById(createViewModel.Table_CheckBox_Trips_Property.ToArray()[i].Id)); } } var cruise = new Cruise() { Name = createViewModel.Name, Description = createViewModel.Description, CruiseCode = createViewModel.CruiseCode, CruiseNumerous = createViewModel.CruiseNumerous, Trips = trips }; CruiseService.CreateCruise(cruise); TempData["CruiseId"] = cruise.CruiseId; TempData["CruiseName"] = cruise.Name; TempData["Message"] = CruisesMessage.CreateSuccess; return RedirectToAction("index", "cruises"); }
public void DeleteCruise(Cruise cruise) { CruiseRepository.Delete(cruise); SaveCruise(); }
public void UpdateCruise(Cruise cruise) { CruiseRepository.Update(cruise); SaveCruise(); }
public void CreateCruise(Cruise cruise) { CruiseRepository.Add(cruise); this.SaveCruise(); }