Beispiel #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);
            }
        }
Beispiel #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();
        }
Beispiel #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;
 }
Beispiel #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());
     }
 }
Beispiel #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());
            }
        }
Beispiel #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);
        }
Beispiel #7
0
 public iotContextBase(iotDomain domain) : this(DefaultDbConnStrName)
 {
     this.IotDomain = domain;
 }
Beispiel #8
0
 public iotContext(iotDomain domain) : base(domain)
 {
 }