public IHttpActionResult Post(int storyId, [FromBody] EntryDTO content) { if (ModelState.IsValid) { var newDTO = new EntryDTO { Content = content.Content, StoryId = storyId }; return Ok(_storyServ.AddEntry(newDTO, User.Identity.Name)); } return BadRequest(); }
public EntryDTO AddEntry(EntryDTO newEntry, string userName) { var currentStory = (from s in _storyRepo.FindStoriesByUser(userName) where s.Id == newEntry.StoryId select s).FirstOrDefault(); var Submission = new Entry() { Content = newEntry.Content, Owner = _userRepo.FindByName(userName), Story = currentStory }; _entryRepo.Add(Submission); _entryRepo.SaveChanges(); return new EntryDTO() { Content = Submission.Content }; }