// GET: Quote/Edit/5 public ActionResult Edit(int id) { var detail = QuoteService.GetQuoteById(id); var model = new QuoteEditModel { QuoteId = detail.QuoteId, Quote = detail.Quote, Description = detail.Description, KidName = detail.KidName, }; return(View(model)); }
public IHttpActionResult Put(QuoteEditModel quote) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateQuoteService(); if (!service.UpdateQuote(quote)) { return(InternalServerError()); } return(Ok()); }
//TODO: Debug.... public bool UpdateQuote(QuoteEditModel model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Quotes .Single(e => e.QuoteId == model.QuoteId && e.OwnerId == _userId); entity.Quote = model.Quote; entity.Description = model.Description; entity.KidName = model.KidName; entity.ModifiedUtc = DateTimeOffset.UtcNow; return(ctx.SaveChanges() == 1); } }
public ActionResult Edit(int id, QuoteEditModel model) { if (!ModelState.IsValid) { return(View(model)); } if (model.QuoteId != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } if (QuoteService.UpdateQuote(model)) { TempData["SaveResult"] = "Your note was updated"; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your note could not be updated."); return(View(model)); }
public bool UpdateQuote(QuoteEditModel model) { throw new NotImplementedException(); }