public IHttpActionResult Post(DreamCreate dream) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateDreamService(); if (!service.CreateDream(dream)) { return(InternalServerError()); } return(Ok()); }
public bool CreateDream(DreamCreate model) { var entity = new Dream() { OwnerId = _userId, Title = model.Title, Description = model.Description, Location = model.Location, Takeaway = model.Takeaway, Rating = model.Rating }; using (var ctx = new ApplicationDbContext()) { ctx.Dreams.Add(entity); return(ctx.SaveChanges() == 1); } }