public IHttpActionResult Post(SpecialCreate special) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateSpecialService(); if (!service.CreateSpecial(special)) { return(InternalServerError()); } return(Ok()); }
public bool CreateSpecial(SpecialCreate model) { var entity = new Special() { ProductId = model.ProductId, SpecialId = model.SpecialId, DayOfWeek = model.DayOfWeek, ProductSpecialPrice = model.ProductSpecialPrice }; using (var ctx = new ApplicationDbContext()) { ctx.Specials.Add(entity); return(ctx.SaveChanges() >= 1); } }