Beispiel #1
0
        public EmployeeTeamDTO PostEmployeeTeam([FromBody] EmployeeTeamDTO e)
        {
            var a = db.EmployeeTeam.Add(converter.DTOToEmployeeTeam(e));

            db.SaveChanges();

            return(converter.EmployeeTeamToDTO(a.Entity));
        }
Beispiel #2
0
        public EmployeeTeamDTO PutEmployeeTeam(int id, [FromBody] EmployeeTeamDTO e)
        {
            var empTeam = dbm.FindEmployeeTeamByID(id);

            if (empTeam.Employee.EmployeeID != e.EmployeeID)
            {
                empTeam.Employee = dbm.FindEmployeeByID(e.EmployeeID);
            }
            if (empTeam.Team.TeamID != e.TeamID)
            {
                empTeam.Team = dbm.FindTeamByID(e.TeamID);
            }

            db.SaveChanges();
            return(converter.EmployeeTeamToDTO(empTeam));
        }
Beispiel #3
0
 public EmployeeTeam DTOToEmployeeTeam(EmployeeTeamDTO a)
 {
     return(new EmployeeTeam {
         Employee = dbm.FindEmployeeByID(a.EmployeeID), EmployeeTeamID = a.EmployeeTeamID, Team = dbm.FindTeamByID(a.TeamID)
     });
 }