// GET api/<controller>/5 public TEProjectTowerModel Get(int id) { TEProjects_TOWER item = db.TEProjects_TOWER.Find(id); TEProjectTowerModel model = new TEProjectTowerModel(); TETransformEntityNModel translator = new TETransformEntityNModel(); model = translator.TransformAtoB(item, model); #region Commented due to entity change //if (item.PROJECT_ID.Value > 0) //{ // TEProject pro = db.TEProjects.Find(item.PROJECT_ID.Value); // if (pro != null) // model.TowerInProject = new TEProject // { // Uniqueid = pro.Uniqueid, // ProjectCode = pro.ProjectCode, // ProjectName = pro.ProjectName, // ProjectShortName = pro.ProjectShortName, // ProjectStatus = pro.ProjectStatus, // IsNewProject = pro.IsNewProject, // City = pro.City, // COLOURCODE = pro.COLOURCODE, // }; //} #endregion return(model); }
// GET api/<controller> public IEnumerable <TEProjectTowerModel> Get() { db.Configuration.ProxyCreationEnabled = false; List <TEProjects_TOWER> list = db.TEProjects_TOWER.Where(x => x.IsDeleted == false).ToList(); List <TEProjectTowerModel> result = new List <TEProjectTowerModel>(); foreach (var item in list) { TEProjectTowerModel model = new TEProjectTowerModel(); TETransformEntityNModel translator = new TETransformEntityNModel(); model = translator.TransformAtoB(item, model); #region Commented due to entity change //if (item.PROJECT_ID!=null) //{ // TEProject pro = db.TEProjects.Find(item.PROJECT_ID.Value); // if(pro!=null) // model.TowerInProject = new TEProject // { // Uniqueid = pro.Uniqueid, // ProjectCode=pro.ProjectCode, // ProjectName=pro.ProjectName, // ProjectShortName=pro.ProjectShortName, // ProjectStatus=pro.ProjectStatus, // IsNewProject=pro.IsNewProject, // City=pro.City, // COLOURCODE=pro.COLOURCODE, // }; //} //if (model.TowerInProject == null) //{ // model.TowerInProject = new TEProject(); //} #endregion result.Add(model); } return(result); }