コード例 #1
0
        public ActionResult Delete(int id)
        {
            var svc   = new SpaceShipService();
            var model = svc.GetSpaceShipById(id);

            return(View(model));
        }
コード例 #2
0
        // GET: SpaceShip
        public ActionResult Index()
        {
            var service = new SpaceShipService();
            var model   = service.GetAllSpaceShips();

            return(View(model));
        }
コード例 #3
0
        public ActionResult DeleteShip(int id)
        {
            var service = new SpaceShipService();

            service.DeleteSpaceShip(id);
            TempData["SaveResult"] = "Your ship was deleted.";
            return(RedirectToAction("Index"));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        // 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));
        }
コード例 #6
0
        //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));
        }
コード例 #7
0
        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));
        }
コード例 #8
0
        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));
        }