public ActionResult Create(Cargo model) { if (ModelState.IsValid) { var cargoId = Guid.NewGuid(); try { // Opdracht 1c // Create new cargo command if (model.VoyageId != null) { // Opdracht 3c // Add cargo to voyage command } } catch (NotEnoughtCapacityLeftForCargoException) { return RedirectToAction("CouldNotBeAddedToVoyage"); } catch (Exception ex) { ModelState.AddModelError("CargoCreationFailed", ex); return View(); } } return RedirectToAction("Index"); }
public ActionResult Create(Cargo model) { if (ModelState.IsValid) { var id = Guid.NewGuid(); try { CreateNewCargoCommand createCommand = new CreateNewCargoCommand { Id = id, Destination = model.Destination, Origin = model.Origin, Size = model.Size, Weight = model.Weight }; MvcApplication.CommandService.Execute(createCommand); } catch (Exception ex) { ModelState.AddModelError("CargoCreationFailed", ex); return View(); } try { if (model.VoyageId != null) { var AddCargoToVoyageCommand = new AddCargoToVoyageCommand { CargoId = id, VoyageId = (Guid)model.VoyageId, CargoSize = model.Size, }; MvcApplication.CommandService.Execute(AddCargoToVoyageCommand); } } catch (NotEnoughCapacityLeftForCargoException ex) { return RedirectToAction("CouldNotBeAddedToVoyage"); } } return RedirectToAction("Index"); }
partial void UpdateCargo(Cargo instance);
partial void DeleteCargo(Cargo instance);
partial void InsertCargo(Cargo instance);