public void SetTeamToProjectMap(TeamToProject tpmap, TypeOfDBAction type) { Project p = GetProject(tpmap.ProjectID); if (p == null) { return; } Team t = GetTeam(tpmap.teamID); if (t == null) { return; } switch (type) { case TypeOfDBAction.Add: p.Teams.Add(t); break; case TypeOfDBAction.Delete: p.Teams.Remove(t); break; } db.SaveChanges(); }
public string RemoveTeamFromProject([FromBody] TeamToProject teamToProject) { using (DataAccessLayer modelAccess = new DataAccessLayer()) { try { LogHelper.WarnLog("Removing Team: " + teamToProject.teamID + " From Project: " + teamToProject.ProjectID); modelAccess.SetTeamToProjectMap(teamToProject, TypeOfDBAction.Delete); return("Ok"); } catch (Exception ex) { LogHelper.ErrorLog("Error Removing Team: " + teamToProject.teamID + " from Project: " + teamToProject.ProjectID); return("Error"); } } }
public string AddTeamToProject([FromBody] TeamToProject teamToProject) { using (DataAccessLayer modelAccess = new DataAccessLayer()) { try { LogHelper.InfoLog("Adding Team: " + teamToProject.teamID + " To Project: " + teamToProject.ProjectID); modelAccess.SetTeamToProjectMap(teamToProject, TypeOfDBAction.Add); return("Ok"); } catch (Exception ex) { LogHelper.ErrorLog("Error Adding team: " + teamToProject.teamID + " to project: " + teamToProject.ProjectID + " with error: " + ex.ToString()); return("Error"); } } }