Esempio n. 1
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));
        }
Esempio n. 2
0
 //update
 //test
 public bool UpdateLaunchSite(LaunchSiteEdit model)
 {
     using (var ctx = new ApplicationDbContext())
     {
         var oldData =
             ctx
             .LaunchSites
             .Single(s => s.Id == model.Id);
         oldData.Id          = model.Id;
         oldData.Name        = model.Name;
         oldData.Location    = model.Location;
         oldData.ModifiedUtc = DateTimeOffset.Now;
         return(ctx.SaveChanges() == 1);
     }
 }
Esempio n. 3
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));
        }