Esempio n. 1
0
        public bool UpdatePropertyPortfolio(PropertyVo propertyVo, int userId)
        {
            PropertyDao propertyDao = new PropertyDao();
            bool        bResult     = false;

            try
            {
                bResult = propertyDao.UpdatePropertyPortfolio(propertyVo, userId);
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();

                FunctionInfo.Add("Method", "PropertyBo.cs:UpdatePropertyPortfolio()");


                object[] objects = new object[2];
                objects[0] = propertyVo;
                objects[1] = userId;

                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }

            return(bResult);
        }
Esempio n. 2
0
        public IHttpActionResult Get(Guid?ownerId = null)
        {
            var propertyDao = new PropertyDao();

            if (ownerId.HasValue)
            {
                return(Ok(propertyDao.GetPropertiesForOwner(ownerId.Value)));
            }
            else
            {
                return(Ok(propertyDao.GetAllProperties()));
            }
        }
Esempio n. 3
0
        // DELETE: api/Owners/5
        public IHttpActionResult Delete(Guid id)
        {
            var propertyDao = new PropertyDao();
            var didDelete   = propertyDao.DeleteProperty(id);

            if (didDelete)
            {
                return(StatusCode(HttpStatusCode.NoContent));
            }
            else
            {
                return(NotFound());
            }
        }
Esempio n. 4
0
        // PUT: api/Ownerss/5
        public IHttpActionResult Put(Guid id, [FromBody] EditableProperty editableProperty)
        {
            var propertyDao   = new PropertyDao();
            var foundProperty = propertyDao.UpdateProperty(id, editableProperty);

            if (foundProperty == null)
            {
                return(NotFound());
            }
            else
            {
                return(Ok(foundProperty));
            }
        }
Esempio n. 5
0
        // GET: api/Owners/5
        public IHttpActionResult Get(Guid id)
        {
            var propertyDao   = new PropertyDao();
            var foundProperty = propertyDao.GetPropertyById(id);

            if (foundProperty == null)
            {
                return(NotFound());
            }
            else
            {
                return(Ok(foundProperty));
            }
        }
Esempio n. 6
0
        public IEnumerable<Position> Get(double north, double east, double south, double west)
        {
            // need to call DB twice. workaround for now
            if (west > east)
            {
                west = -180;
            }

            PropertyDao dao = new PropertyDao();
            List<Position> data =
                dao.GetByPositionRange(north, east, south, west)
                .Select(r => new Position { Lat = r.Latitude.Value, Lng = r.Longitude.Value })
                .ToList();

            return data;
        }
Esempio n. 7
0
        public void PropertyGetByPositionRange()
        {
            //                North-East
            //   +---------------+
            //   |               |+90
            //   |               |
            //   |               | Latitude
            //   | -180     +180 |
            //   |   Longitude   |-90
            //   +---------------+
            // South-West
            //
            //                North-East
            //   +---------------+
            //   |               |
            //   |               |
            //   |    * +40 -70  |
            //   |               |
            //   |               |
            //   +---------------+
            // South-West

            using (new TransactionScope())
            {
                Client client = NewClient();

                PropertyDao dao = new PropertyDao();
                Property entity = new Property
                {
                    Id = Guid.NewGuid(),
                    Client = client,
                    Name = "foo",
                    Latitude = 40,
                    Longitude = -70
                };
                dao.Add(entity);
                dao.SaveChanges();

                dao.Detach(entity);

                List<Property> list1 = dao.GetByPositionRange(40.1, -69.9, 39.9, -71.1);
                Assert.AreEqual(1, list1.Count);

                List<Property> list2 = dao.GetByPositionRange(39.9, -69.9, 39.8, -71.1);
                Assert.AreEqual(0, list2.Count);
            }
        }
Esempio n. 8
0
        public void PropertySaveAndGet()
        {
            using (new TransactionScope())
            {
                Client client = NewClient();
                PropertyDao dao = new PropertyDao();
                Property entity = new Property
                {
                    Id = Guid.NewGuid(),
                    Client = client,
                    Name = "foo"
                };
                dao.Add(entity);
                dao.SaveChanges();

                dao.Detach(entity);

                Property writtenEntity = dao.GetById(entity.Id);
                Assert.AreEqual(entity.Name, writtenEntity.Name);
            }
        }
 public Property GetPropertyByTableAndColumn(string tableName, string columnName, Guid applicationId)
 {
     return(PropertyDao.FindAllByTableAndColumn(tableName, columnName, applicationId).FirstOrDefault());
 }