/************** Site ************/ public bool SiteAdd(Site site) { try { iotContext db = new iotContext(); iotDomain targetDomain = (from d in db.Domains where site.Domain.Id == d.Id select d).First(); Location siteLocation = (from l in db.Locations where l.Id == site.siteLocation.Id select l).First(); Site nsite = new Site(); nsite.SiteName = site.SiteName; nsite.Domain = targetDomain; nsite.siteLocation = siteLocation; db.Sites.Add(nsite); db.SaveChanges(); return(true); } catch (Exception e) { return(false); } }
public iotRepository() { iotContext dbContext = new iotContext(); DbContext = dbContext; DbSet = DbContext.Set <T>(); }
/************** Type ************/ public ParameterType TypeForName(string name) { try { iotContext db = new iotContext(); List <ParameterType> types = (from d in db.ParamTypes where d.Name.Equals(name) select d).ToList(); if (types.Count == 0) { //add type ParameterType type = new ParameterType(); type.Name = name; ParameterType storedType = db.ParamTypes.Add(type); db.SaveChanges(); return(storedType); } else { return(types.First()); } } catch (Exception e) { return(new ParameterType()); } }
/************** Site ************/ public List <Site> SiteList() { iotContext db = new iotContext(); List <Site> sites = (from d in db.Sites select d).ToList(); return(sites); }
/************** Device ************/ public List <Device> DeviceList() { iotContext db = new iotContext(); List <Device> devs = (from d in db.Devices select d).ToList(); return(devs); }
/************** Device types ************/ public List <DeviceType> DevTypesList() { iotContext db = new iotContext(); List <DeviceType> mappers = (from d in db.Types select d).ToList(); return(mappers); }
/************** Action params ************/ public List <ActionParameter> ActionParamList() { iotContext db = new iotContext(); List <ActionParameter> types = (from d in db.ActionParameters select d).ToList(); return(types); }
/************** Mapper ************/ public List <sconnActionResultMapper> MappersList() { iotContext db = new iotContext(); List <sconnActionResultMapper> mappers = (from d in db.ActionResultMappers select d).ToList(); return(mappers); }
public List <ParameterType> ParamTypeList() { iotContext db = new iotContext(); List <ParameterType> types = (from d in db.ParamTypes select d).ToList(); return(types); }
/************** Action ************/ public List <DeviceAction> ActionList() { iotContext db = new iotContext(); List <DeviceAction> actions = (from d in db.Actions select d).ToList(); return(actions); }
/************** Endpoint ************/ public List <EndpointInfo> EndpInfoList() { iotContext db = new iotContext(); List <EndpointInfo> endp = (from d in db.Endpoints select d).ToList(); return(endp); }
/************** Location ************/ public List <Location> LocationList() { iotContext db = new iotContext(); List <Location> locs = (from d in db.Locations select d).ToList(); return(locs); }
/************** Parameter ************/ public List <DeviceParameter> ParameterList() { iotContext db = new iotContext(); List <DeviceParameter> devparams = (from d in db.Parameters select d).ToList(); return(devparams); }
/************** Property ************/ public List <DeviceProperty> PropertyList() { iotContext db = new iotContext(); List <DeviceProperty> props = (from d in db.Properties select d).ToList(); return(props); }
public List <iotDomain> DomainList() { iotContext db = new iotContext(); List <iotDomain> domains = (from d in db.Domains select d).ToList(); return(domains); }
static public void ClearIotRepository() { iotContext dbContext = new iotContext(); var tableNames = dbContext.Database.SqlQuery <string>("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_NAME NOT LIKE '%Migration%'").ToList(); foreach (var tableName in tableNames) { dbContext.Database.ExecuteSqlCommand(string.Format("DELETE FROM {0}", tableName)); } dbContext.SaveChanges(); }
protected override void Seed(iotDbConnector.DAL.iotContext context) { // This method will be called after migrating to the latest version. // You can use the DbSet<T>.AddOrUpdate() helper extension method // to avoid creating duplicate seed data. E.g. // // context.People.AddOrUpdate( // p => p.FullName, // new Person { FullName = "Andrew Peters" }, // new Person { FullName = "Brice Lambson" }, // new Person { FullName = "Rowan Miller" } // ); // }
public iotDomain DomainForDomainId(int domainId) { try { iotContext db = new iotContext(); iotDomain domain = (from d in db.Domains where d.Id.Equals(domainId) select d).First(); return(domain); } catch (Exception e) { return(new iotDomain()); } }
/**************************** Query ****************************/ /************** Domain ************/ public iotDomain DomainForDomainName(string name) { try { iotContext db = new iotContext(); iotDomain domain = (from d in db.Domains where d.DomainName == name select d).First(); return(domain); } catch (Exception e) { return(new iotDomain()); } }
/**************************** Execute ****************************/ /************** Domain ************/ public bool DomainAdd(iotDomain domain) { try { if (domain != null) { iotContext db = new iotContext(); db.Domains.Add(domain); db.SaveChanges(); //TODO verify save } } catch (Exception e) { } return(true); }
/************** Device ************/ public bool DeviceAdd(Device device) { try { if (device != null) { iotContext db = new iotContext(); db.Devices.Add(device); db.SaveChanges(); //TODO verify save } } catch (Exception e) { } return(true); }
/************** Action ************/ public bool ActionAdd(DeviceAction action) { try { if (action != null) { iotContext db = new iotContext(); db.Actions.Add(action); db.SaveChanges(); //TODO verify save } } catch (Exception e) { } return(true); }
/************** Action param ************/ public bool ActionParamAdd(ActionParameter param) { try { if (param != null) { iotContext db = new iotContext(); db.ActionParameters.Add(param); db.SaveChanges(); //TODO verify save } } catch (Exception e) { } return(true); }
/************** Mapper ************/ public bool MapperAdd(sconnActionResultMapper param) { try { if (param != null) { iotContext db = new iotContext(); db.ActionResultMappers.Add(param); db.SaveChanges(); //TODO verify save } } catch (Exception e) { } return(true); }
/************** Type ************/ public bool TypeAdd(DeviceType param) { try { if (param != null) { iotContext db = new iotContext(); db.Types.Add(param); db.SaveChanges(); //TODO verify save } } catch (Exception e) { } return(true); }
/************** Endpoint ************/ public bool EndpointAdd(EndpointInfo edp) { try { if (edp != null) { iotContext db = new iotContext(); db.Endpoints.Add(edp); db.SaveChanges(); //TODO verify save } } catch (Exception e) { } return(true); }
/************** Location ************/ public bool LocationAdd(Location loc) { try { if (loc != null) { iotContext db = new iotContext(); db.Locations.Add(loc); db.SaveChanges(); //TODO verify save } } catch (Exception e) { } return(true); }
/************** Property ************/ public bool PropertyAdd(DeviceProperty property) { try { if (property != null) { iotContext db = new iotContext(); db.Properties.Add(property); db.SaveChanges(); //TODO verify save } } catch (Exception e) { } return(true); }
public iotConnector() { context = new iotContext(); }