Ejemplo n.º 1
0
        public ActionResult Edit(int id)
        {
            var detail = _funkyFadzService.Value.GetFunkyFadzById(id);
            var model  =
                new FunkyFadzEditModel
            {
                FunkyFadzId = detail.FunkyFadzId,
                FadType     = detail.FadType,
                Description = detail.Description,
                Year        = detail.Year,
            };

            return(View(model));
        }
Ejemplo n.º 2
0
        public IHttpActionResult Put(FunkyFadzEditModel Fad)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateFunkyFadz();

            if (!service.UpdateFunkyFadz(Fad))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
Ejemplo n.º 3
0
        public bool UpdateFunkyFadz(FunkyFadzEditModel model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .FunkyFadz
                    .Single(e => e.FunkyFadzId == model.FunkyFadzId && e.OwnerId == _userId);

                entity.FadType     = model.FadType;
                entity.Description = model.Description;
                entity.Year        = model.Year;
                entity.ModifiedUtc = DateTimeOffset.UtcNow;

                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 4
0
        public ActionResult Edit(int id, FunkyFadzEditModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.FunkyFadzId != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }


            if (_funkyFadzService.Value.UpdateFunkyFadz(model))
            {
                TempData["SaveResult"] = "Your Fad was updated";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Your Fad could not be updated.");
            return(View(model));
        }
Ejemplo n.º 5
0
 public bool UpdateFunkyFadz(FunkyFadzEditModel model)
 {
     throw new NotImplementedException();
 }