Beispiel #1
0
        public Bugs Update(Bugs bugChanges)
        {
            var bug = _context.Bugs.Attach(bugChanges); //Attach the Bugs object that has the changes to the Bugs property.

            bug.State = EntityState.Modified;           //Tell EF that object the was return is modified
            _context.SaveChanges();                     //Update in the database
            return(bugChanges);
        }
Beispiel #2
0
        public Bugs Delete(int?Id)
        {
            Bugs bug = _context.Bugs.Find(Id); //find the bug and stored in a variable bug

            if (bug != null)                   //if bug we wnat to delete is found
            {
                _context.Bugs.Remove(bug);
                _context.SaveChanges(); //save changes in the database
            }
            return(bug);
        }
Beispiel #3
0
        public Bugs GetBugs(int?Id)
        {
            Bugs bug = _context.Bugs.Include(b => b.BugStatus).Include(b => b.BugPriority).Include(b => b.Project).FirstOrDefault(u => u.Id == Id);

            return(bug);
        }
Beispiel #4
0
 public Bugs Add(Bugs bug)
 {
     _context.Bugs.Add(bug);
     _context.SaveChanges();
     return(bug);
 }