public HttpResponseMessage Get(int id)
        {
            EducationModel retr = null;

            try
            {
                Education edu = dbContext.Educations.Find(id);
                if (edu != null)
                {
                    EducationModel eduM = new EducationModel()
                    {
                        eduType = edu.Name,
                        ID      = edu.EducationID,
                    };
                    EmployeeController empCon = new EmployeeController();
                    for (int i = 0; i < edu.Employees.Count; i++)
                    {
                        EmployeeModel empMod = empCon.Get(edu.Employees.ToList()[i].EmployeeID);
                        eduM.employees.Add(empMod);
                    }
                    return(Request.CreateResponse(HttpStatusCode.OK, eduM));
                }
            }
            catch
            {
                return(Request.CreateResponse(HttpStatusCode.Conflict, retr));
            }

            return(Request.CreateResponse(HttpStatusCode.NotFound, retr));
        }
Ejemplo n.º 2
0
 public HttpResponseMessage Get(int id)
 {
     try
     {
         State      sta = dbContext.States.Find(id);
         StateModel stm = new StateModel()
         {
             ID    = id,
             state = sta.Name,
         };
         for (int i = 0; i < sta.Employees.Count; i++)
         {
             EmployeeController empCon = new EmployeeController();
             EmployeeModel      EmpMod = empCon.Get(sta.Employees.ToList()[i].EmployeeID);
             stm.employees.Add(EmpMod);
         }
         return(Request.CreateResponse(HttpStatusCode.OK, stm));
     }
     catch
     {
         return(Request.CreateResponse(HttpStatusCode.Conflict));
     }
 }