示例#1
0
        public IHttpActionResult Put(SpecialUpdate special)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateSpecialService();

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

            return(Ok());
        }
示例#2
0
        public bool UpdateSpecial(SpecialUpdate model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Specials
                    .Single(e => e.SpecialId == model.SpecialId);

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

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