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)); }
public IHttpActionResult Put(FunkyFadzEditModel Fad) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateFunkyFadz(); if (!service.UpdateFunkyFadz(Fad)) { return(InternalServerError()); } return(Ok()); }
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); } }
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)); }
public bool UpdateFunkyFadz(FunkyFadzEditModel model) { throw new NotImplementedException(); }