public IHttpActionResult Post(AdventureCreate adventure) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateAdventureService(); if (!service.CreateAdventure(adventure)) { return(InternalServerError()); } return(Ok()); }
public bool CreateAdventure(AdventureCreate model) { var entity = new Adventure() { OwnerId = _userId, Title = model.Title, Description = model.Description, CreatedUtc = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.Adventures.Add(entity); return(ctx.SaveChanges() == 1); } }