public void DeleteTeam(Team team) { if (team == null) { throw new ArgumentNullException(nameof(team)); } _context.Teams.Remove(team); _context.SaveChanges(); }
public void DeleteTicket(Ticket ticket) { if (ticket == null) { throw new ArgumentNullException(nameof(ticket)); } _context.Tickets.Remove(ticket); _context.SaveChanges(); }
public void DeleteAssignment(Assignment assignment) { if (assignment == null) { throw new ArgumentNullException(nameof(assignment)); } _context.Assignments.Remove(assignment); _context.SaveChanges(); }
public void DeleteSprint(Sprint sprint) { if (sprint == null) { throw new ArgumentNullException(nameof(sprint)); } _context.Sprints.Remove(sprint); _context.SaveChanges(); }
public void SeedProjects() { _context.Database.EnsureCreated(); if (!_context.Projects.Any()) { var filePath = Path.Combine(_env.ContentRootPath, "Data/ProjectExamples.json"); var json = File.ReadAllText(filePath); var projects = JsonSerializer.Deserialize <IEnumerable <Project> >(json); _context.Projects.AddRange(projects); _context.SaveChanges(); } }
public bool SaveChanges() { return(_context.SaveChanges() >= 0); }
public static void Initialize(BugTrackerContext context) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); if (context.Users.Any()) { return; } var users = new List <User>(); var projects = new List <Project>(); var tickets = new List <Ticket>(); var comments = new List <Comment>(); var attachments = new List <Attachment>(); Project project = new Project { Id = 1, Title = "project", Description = "description" }; User Andrei = new User { Name = "Andrei", Email = "*****@*****.**", Id = 1, Role = Role.Admin }; User Stefan = new User { Name = "Stefan", Email = "*****@*****.**", Id = 2, Role = Role.ProjectManager }; User Greg = new User { Name = "Greg", Email = "*****@*****.**", Id = 3, Role = Role.Developer }; User Robert = new User { Name = "Robert", Email = "*****@*****.**", Id = 4, Role = Role.Submitter }; Ticket ticket = new Ticket { Id = 1, Title = "ticket", Description = "description", Priority = Priority.High, Status = Status.InProgress, Type = Type.Bugs, CreatedDateTime = DateTime.Now, UpdatedDateTime = DateTime.Now }; Comment comment = new Comment { Id = 1, CreatedDateTime = DateTime.Now, Message = "make better" }; Attachment attachment = new Attachment { Id = 1, CreatedDateTime = DateTime.Now, Notes = "null file" }; users.Add(Andrei); users.Add(Stefan); users.Add(Greg); users.Add(Robert); tickets.Add(ticket); comments.Add(comment); attachments.Add(attachment); projects.Add(project); //Andrei.Projects = projects; foreach (User u in users) { context.Users.Add(u); } context.SaveChanges(); foreach (Project p in projects) { context.Projects.Add(p); } context.SaveChanges(); foreach (Ticket t in tickets) { context.Tickets.Add(t); } context.SaveChanges(); foreach (Comment c in comments) { context.Comments.Add(c); } context.SaveChanges(); foreach (Attachment a in attachments) { context.Attachments.Add(a); } context.SaveChanges(); }