public bool CreateFlavor(FlavorCreate model) { var entity = new Flavor() { FlavorName = model.FlavorName, FlavorDesc = model.FlavorDesc }; using (var ctx = new ApplicationDbContext()) { ctx.Flavors.Add(entity); return(ctx.SaveChanges() == 1); } }
public IHttpActionResult Post(FlavorCreate flavor) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = new FlavorService(); if (!service.CreateFlavor(flavor)) { return(InternalServerError()); } return(Ok()); }