public ActionResult Delete(int id) { var svc = new SpaceShipService(); var model = svc.GetSpaceShipById(id); return(View(model)); }
// GET: SpaceShip public ActionResult Index() { var service = new SpaceShipService(); var model = service.GetAllSpaceShips(); return(View(model)); }
public ActionResult DeleteShip(int id) { var service = new SpaceShipService(); service.DeleteSpaceShip(id); TempData["SaveResult"] = "Your ship was deleted."; return(RedirectToAction("Index")); }
public ActionResult ShipOrigin(int?LaunchSiteId) { var service = new SpaceShipService(); var ships = service.GetAllSpaceShips(); var shipOrigin = (from s in ships where (LaunchSiteId == null || s.LaunchSiteId == LaunchSiteId) select s).ToList(); return(View(shipOrigin)); }
// GET: SpaceShip public ActionResult Index(string searchString) { var service = new SpaceShipService(); var model = service.GetAllSpaceShips(); if (!String.IsNullOrEmpty(searchString)) { model = model.Where(s => s.ShipName.Contains(searchString)).ToList(); } return(View(model)); }
//Get public ActionResult Edit(int id) { var service = new SpaceShipService(); var detail = service.GetSpaceShipById(id); var model = new SpaceShipEdit { Id = detail.Id, ShipName = detail.ShipName, CrewCapacity = detail.CrewCapacity }; return(View(model)); }
public ActionResult Create(SpaceShipCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = new SpaceShipService(); if (service.CreateSpaceShip(model)) { TempData["SaveResult"] = "Your SpaceShip was created."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "SpaceShip could not be created."); return(View(model)); }
public ActionResult Edit(int id, SpaceShipEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.Id != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } var service = new SpaceShipService(); if (service.UpdateSpaceShip(model)) { TempData["SaveResult"] = "Your ship was updated!"; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your ship could not be updated."); return(View(model)); }