public IActionResult CompletedBug([FromRoute] long id) { try { var bug = _context.Bugs.Where(x => x.Id.Equals(id)).Single(); bug.IsFixed = true; _context.SaveChanges(); return(Ok()); } catch { return(NotFound()); } }
public IdeaResult Add(string title, string text) { bool ideaExist = true; try { var ideaPromise = _DBcontext.Ideas .Where(m => m.Title == title) .Single(); } catch { ideaExist = false; } try { if (ideaExist == true) { return(null); } var idea = new Idea(title) { Definitions = new List <Definition>() }; var definition = new Definition(text) { IdeaId = idea.IdeaId }; idea.Definitions.Add(definition); _DBcontext.Ideas.Add(idea); _DBcontext.SaveChanges(); return(_mapper.Map(idea)); } catch { return(null); } }