Ejemplo n.º 1
0
        public IHttpActionResult Put([FromUri] int specialId, [FromBody] SpecialEdit special)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateSpecialService();

            if (!service.UpdateSpecial(specialId, special))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
Ejemplo n.º 2
0
        public bool UpdateSpecial(int specialId, SpecialEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Specials
                    .Single(e => e.SpecialId == specialId);

                entity.SpecialId           = model.SpecialId;
                entity.ProductId           = model.ProductId;
                entity.DayOfWeek           = model.DayOfWeek;
                entity.ProductSpecialPrice = model.ProductSpecialPrice;

                return(ctx.SaveChanges() == 1);
            }
        }