コード例 #1
0
        // GET: LaunchSite
        public ActionResult Index()
        {
            var service = new LaunchSiteService();
            var model   = service.GetAllLaunchSites();

            return(View(model));
        }
コード例 #2
0
        public ActionResult Delete(int id)
        {
            var svc   = new LaunchSiteService();
            var model = svc.GetLaunchSiteById(id);

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

            service.DeleteLaunchSite(id);
            TempData["SaveResult"] = "Your Launch Site was deleted.";
            return(RedirectToAction("Index"));
        }
コード例 #4
0
        // GET: LaunchSite
        //full list or filter by location
        public ActionResult Index(string searchString)
        {
            var service = new LaunchSiteService();
            var model   = service.GetAllLaunchSites();

            if (!String.IsNullOrEmpty(searchString))
            {
                model = model.Where(s => s.Location.Contains(searchString)).ToList();
            }
            return(View(model));
        }
コード例 #5
0
        //Get
        public ActionResult Edit(int id)
        {
            var service = new LaunchSiteService();
            var detail  = service.GetLaunchSiteById(id);
            var model   =
                new LaunchSiteEdit
            {
                Id       = detail.Id,
                Name     = detail.Name,
                Location = detail.Location
            };

            return(View(model));
        }
コード例 #6
0
        public ActionResult Create(LaunchSiteCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var service = new LaunchSiteService();

            if (service.CreateLaunchSite(model))
            {
                TempData["SaveResult"] = "Your Launch Site was created!";
                return(RedirectToAction("Index"));
            }
            ;
            ModelState.AddModelError("", "Launch Site could not be created.");
            return(View(model));
        }
コード例 #7
0
        public ActionResult Edit(int id, LaunchSiteEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            if (model.Id != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }
            var service = new LaunchSiteService();

            if (service.UpdateLaunchSite(model))
            {
                TempData["SaveResult"] = "Your Launch Site was updated!";
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "Your Launch Site could not be updated.");
            return(View(model));
        }