Exemplo n.º 1
0
        /************** 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);
            }
        }
Exemplo n.º 2
0
        public void Fake()
        {
            Location loc = new Location();

            loc.Lat          = 1.11;
            loc.Lng          = 22.11;
            loc.LocationName = Guid.NewGuid().ToString();
            this.Locations.Add(loc);
            this.SaveChanges();
            Location  storedloc = this.Locations.FirstOrDefault(nl => nl.LocationName == loc.LocationName);
            iotDomain d         = new iotDomain();

            d.DomainName = Guid.NewGuid().ToString();
            d.Id         = 0;
            d.Sites      = new List <Site>();
            this.Domains.Add(d);
            this.SaveChanges();

            iotDomain stored = this.Domains.First(s => s.DomainName == d.DomainName);
            Site      site   = new Site();

            site.Id       = 0;
            site.Devices  = new List <Device>();
            site.Domain   = stored;
            site.SiteName = Guid.NewGuid().ToString();
            this.Sites.Add(site);
            this.SaveChanges();
        }
Exemplo n.º 3
0
 public void Load(Site other)
 {
     this.Devices      = other.Devices;
     this.Domain       = other.Domain;
     this.Id           = other.Id;
     this.SiteName     = other.SiteName;
     this.siteLocation = other.siteLocation;
 }
Exemplo n.º 4
0
 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());
     }
 }
Exemplo n.º 5
0
        /**************************** 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());
            }
        }
Exemplo n.º 6
0
        /**************************** 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);
        }
Exemplo n.º 7
0
 public iotContextBase(iotDomain domain) : this(DefaultDbConnStrName)
 {
     this.IotDomain = domain;
 }
Exemplo n.º 8
0
 public iotContext(iotDomain domain) : base(domain)
 {
 }