public bool UpdateQuote(QuoteEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Quotes
                    .SingleOrDefault(e => e.QuoteId == model.QuoteId);

                entity.Content    = model.Content;
                entity.DateSpoken = model.DateSpoken;

                return(ctx.SaveChanges() == 1);
            }
        }
Example #2
0
        public IHttpActionResult Put(QuoteEdit quote)
        {
            if (quote == null)
            {
                return(BadRequest("Received model was null."));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var service = CreateQuoteService();

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