public IHttpActionResult Post(Idea idea) { if (idea == null) { return(BadRequest("Need more information about the idea")); } if (string.IsNullOrEmpty(idea.Title)) { return(BadRequest("Idea needs a Title")); } var project = GetProject(idea.ProjectId); var dbIdea = new Data.Idea { Title = idea.Title, Description = idea.Description, WhenAdded = DateTime.Now, Importance = idea.Importance }; project.Ideas.Add(dbIdea); _context.SaveChanges(); return(Ok(Map(dbIdea))); }
private static Idea Map(Data.Idea idea) { return(new Idea { Id = idea.Id, Title = idea.Title, Description = idea.Description, Importance = idea.Importance, WhenAdded = idea.WhenAdded, ProjectId = idea.Project.Id }); }