public ActionResult Edit(int id)
        {
            var service = CreatePlanetService();
            var detail  = service.GetPlanetById(id);
            var model   =
                new PlanetEdit
            {
                PlanetaryName = detail.PlanetaryName,
            };

            return(View(model));
        }
Beispiel #2
0
 public bool UpdatePlanet(PlanetEdit model)
 {
     using (var ctx = new ApplicationDbContext())
     {
         var planetEntity = ctx.Planets
                            .Single(e => e.PlanetId == model.PlanetId && _userId == e.UserId);
         planetEntity.Name           = model.Name;
         planetEntity.PrimaryColor   = model.PrimaryColor;
         planetEntity.SecondaryColor = model.SecondaryColor;
         return(ctx.SaveChanges() == 1);
     }
 }
Beispiel #3
0
 public bool UpdatePlanet(PlanetEdit model)
 {
     using (var ctx = new ApplicationDbContext())
     {
         var entity =
             ctx
             .Planets
             .Single(e => e.PlanetId == model.PlanetId && _ownerId == e.UserId);
         entity.PlanetaryName = model.PlanetaryName;
         return(ctx.SaveChanges() == 1);
     }
 }
Beispiel #4
0
        public ActionResult Edit(int id)
        {
            var service = CreatePlanetService();
            var edit    = service.GetPlanetById(id);
            var model   =
                new PlanetEdit
            {
                Name           = edit.Name,
                PrimaryColor   = edit.PrimaryColor,
                SecondaryColor = edit.SecondaryColor
            };

            return(View(model));
        }
Beispiel #5
0
        public ActionResult Edit(PlanetEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var service = CreatePlanetService();

            if (service.UpdatePlanet(model))
            {
                TempData["SaveResult"] = "Your Planet was Succesfully Updated";
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", "Your Planet Was Not Updated");
            return(View(model));
        }