Exemplo n.º 1
0
        // 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));
        }
Exemplo n.º 2
0
        public IHttpActionResult Put(QuoteEditModel quote)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateQuoteService();

            if (!service.UpdateQuote(quote))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
Exemplo n.º 3
0
        //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);
            }
        }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 5
0
 public bool UpdateQuote(QuoteEditModel model)
 {
     throw new NotImplementedException();
 }