public static List <CommandModel> GetAllCommands() { using (var data = new SmartHomeLocalDbEntities()) { return(data.Commands.Select(x => new CommandModel() { Id = x.Id, Code = x.Code, Description = x.Description }).ToList()); } }
public static List<DeviceModel> GetAllDevices() { using (var data = new SmartHomeLocalDbEntities()) { return data.Devices.Select(x => new DeviceModel() { Id = x.Id, Name = x.Name, DateOfReg = x.DateOfReg, URL = x.URL }).ToList(); } }
public static List <ReturnLogModel> GetAllReturnLogs() { using (var data = new SmartHomeLocalDbEntities()) { return(data.ReturnLogs.Select(x => new ReturnLogModel() { Id = x.Id, JobId = x.JobId, Time = x.Time, Value = x.Value }).ToList()); } }
public static List <ActionModel> GetAllActions() { using (var data = new SmartHomeLocalDbEntities()) { var query = from a in data.Actions join d in data.Devices on a.DeviceId equals d.Id join c in data.Commands on a.CommandId equals c.Id select new ActionModel() { Id = a.Id, DeviceId = a.DeviceId, DeviceName = d.Name, CommandId = a.CommandId, CommandCode = c.Code, Description = (a.Description == null) ? c.Description : a.Description }; return(query.ToList()); } }
public static List <JobModel> GetAllJobs() { using (var data = new SmartHomeLocalDbEntities()) { var query = from j in data.Jobs join a in data.Actions on j.ActionId equals a.Id join d in data.Devices on a.DeviceId equals d.Id join c in data.Commands on a.CommandId equals c.Id select new JobModel() { Id = j.Id, ActionId = j.ActionId, DeviceName = d.Name, CommandCode = c.Code, Time = j.Time, RepeatTimeMinutes = j.RepeatTimeMinutes, RepeatTimeSeconds = j.RepeatTimeSeconds, IsSensor = j.IsSensor }; return(query.ToList()); } }