public IHttpActionResult Report(Flag flag)
 {
     if (ModelState.IsValid)
     {
         var result = new FlagRepository().ReportAnIssue(flag);
         return Ok(result);
     }
     return new System.Web.Http.Results.ExceptionResult(new System.Exception(), this);
 }
        public bool ReportAnIssue(Flag flag)
        {
            var exisitingFlag = _context.Flags.FirstOrDefault(x => x.Id == flag.Id);

            if (exisitingFlag != null)
            {
                exisitingFlag.Agent = flag.Agent;
                exisitingFlag.Field = flag.Field;
                exisitingFlag.Screen = flag.Screen;
                exisitingFlag.Comment = flag.Comment;
            }
            else
                _context.Flags.Add(flag);
            _context.Entry(flag.Agent).State = EntityState.Unchanged;
            _context.Entry(flag.Screen).State = EntityState.Unchanged;
            _context.Entry(flag.Field).State = EntityState.Unchanged;
            _context.SaveChanges();

            return true;
        }