Esempio n. 1
0
 // GET api/system/5
 public SystemDTO Get(int id)
 {
     Systems system = db.Systems.FirstOrDefault(el => el.Id == id);
     SystemDTO systemModels = new SystemDTO();
     systemModels.id = system.Id;
     systemModels.name = system.Name;
     systemModels.goal = system.Goal;
     return systemModels;
 }
Esempio n. 2
0
        // GET api/system
        public IEnumerable<SystemDTO> Get()
        {
            string userId = GetUserId();

            var userSystems = from systems in db.Systems
                              where systems.User == userId
                              select systems;
            List<SystemDTO> systemList= new List<SystemDTO>();

            foreach (Systems s in userSystems) {
                SystemDTO newSys = new SystemDTO();
                newSys.id = s.Id;
                newSys.name = s.Name;
                newSys.goal = s.Goal;
                systemList.Add(newSys);
            }

            return systemList.ToArray();
        }