Esempio n. 1
0
        public async Task <bool> DeleteTrainingValues(Space space)
        {
            var trainingValues = db.TrainingValues.Where(x => x.Space.ID == space.ID);

            if (trainingValues.Any())
            {
                foreach (TrainingValue tv in trainingValues)
                {
                    db.Entry(tv).State = EntityState.Deleted;
                }
            }
            return(true);
        }
        //    // GET: api/Addresses
        //    public IQueryable<Address> GetAddresses()
        //    {
        //        return db.Addresses;
        //    }

        //    // GET: api/Addresses/5
        //    [ResponseType(typeof(Address))]
        //    public async Task<IHttpActionResult> GetAddress(int id)
        //    {
        //        Address address = await db.Addresses.FindAsync(id);
        //        if (address == null)
        //        {
        //            return NotFound();
        //        }

        //        return Ok(address);
        //    }

        //    // PUT: api/Addresses/5
        //    [ResponseType(typeof(void))]
        //    public async Task<IHttpActionResult> PutAddress(int id, Address address)
        //    {
        //        if (!ModelState.IsValid)
        //        {
        //            return BadRequest(ModelState);
        //        }

        //        //if (id != address.ID)
        //        //{
        //        //    return BadRequest();
        //        //}

        //        db.Entry(address).State = EntityState.Modified;

        //        try
        //        {
        //            await db.SaveChangesAsync();
        //        }
        //        catch (DbUpdateConcurrencyException)
        //        {
        //            //if (!AddressExists(id))
        //            //{
        //            //    return NotFound();
        //            //}
        //            //else
        //            //{
        //            //    throw;
        //            //}
        //        }

        //        return StatusCode(HttpStatusCode.NoContent);
        //    }

        //    // POST: api/Addresses
        //    [ResponseType(typeof(Address))]
        //    public async Task<IHttpActionResult> PostAddress(Address address)
        //    {
        //        if (!ModelState.IsValid)
        //        {
        //            return BadRequest(ModelState);
        //        }

        //        db.Addresses.Add(address);
        //        await db.SaveChangesAsync();

        //        return CreatedAtRoute("DefaultApi", new { id = address.ID }, address);
        //    }

        public async Task <bool> DeleteAddress(Guid id)
        {
            var address = db.Addresses.Where(x => x.Building.ID == id);

            db.Entry(address.First()).State = EntityState.Deleted;
            return(true);
        }
        public void SetStatus(int ID, Space space, string status)
        {
            Tracker tracker = GetTracker(ID);

            tracker.trainingLocation = space;
            tracker.Status           = status;
            db.Entry(tracker).State  = EntityState.Modified;
            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }
        }
        public bool PutStorey(Storey s)
        {
            if (db.Storeys.Find(s.ID) == null)
            {
                return(false);
            }
            Storey storey = db.Storeys.Find(s.ID);

            storey.Name            = s.Name;
            db.Entry(storey).State = EntityState.Modified;
            try
            {
                db.SaveChanges();
            }
            catch (System.Data.Entity.Infrastructure.DbUpdateConcurrencyException)
            {
                throw;
            }
            return(true);
        }
        public bool PutBuilding(Building b)
        {
            Building building = db.Buildings.Find(b.ID);

            if (building == null)
            {
                return(false);
            }

            building.Name            = b.Name;
            db.Entry(building).State = EntityState.Modified;
            try
            {
                db.SaveChanges();
            }
            catch (System.Data.Entity.Infrastructure.DbUpdateConcurrencyException)
            {
                throw;
            }
            return(true);
        }
Esempio n. 6
0
        public async Task <bool> setStoreyNull(Storey storey)
        {
            var knns = db.Knn.Where(x => x.Storey.ID == storey.ID);

            if (knns.Any())
            {
                foreach (Knn knn in knns)
                {
                    knn.Storey          = null;
                    db.Entry(knn).State = EntityState.Modified;
                }
            }
            return(true);
        }
        public async Task <bool> setStoreyNull(Storey storey)
        {
            var beacons = from b in db.Beacons where b.Storey.ID == storey.ID select b;

            if (beacons.Any())
            {
                foreach (Beacon beacon in beacons)
                {
                    beacon.Storey          = null;
                    db.Entry(beacon).State = EntityState.Modified;
                }
            }
            return(true);
        }
Esempio n. 8
0
        public void PutOrientation(TrackerOrientation tO)
        {
            var trackerOrientations = db.TrackerOrientations.Where(x => x.Tracker.ID == tO.Tracker.ID);

            if (trackerOrientations.Count() == 0)
            {
                db.TrackerOrientations.Add(tO);
            }
            else
            {
                var trackerOrientation = trackerOrientations.First();
                trackerOrientation.Orientation     = tO.Orientation;
                trackerOrientation.TimeStamp       = tO.TimeStamp;
                db.Entry(trackerOrientation).State = EntityState.Modified;
            }
            try
            {
                db.SaveChanges();
            }
            catch (System.Data.Entity.Infrastructure.DbUpdateConcurrencyException)
            {
                throw;
            }
        }