public IHttpActionResult Post(CakeCreate cake) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateCakeService(); if (!service.CreateCake(cake)) { return(InternalServerError()); } return(Ok()); }
public bool CreateCake(CakeCreate model) { var entity = new Cake() { UserId = _userId, Flavor = model.Flavor, Toppings = model.Toppings, Icing = model.Icing, }; using (var ctx = new ApplicationDbContext()) { ctx.Cakes.Add(entity); return(ctx.SaveChanges() == 1); } }