Example #1
0
        public bool CreateProperty(PropertyCreate model)
        {
            TenantService tenantService = new TenantService(_ownerId);
            Result        LocationData  = GetLocationData(model.Address);
            var           entity        =
                new Property
            {
                OwnerId         = _ownerId,
                Address         = model.Address,
                City            = model.City,
                State           = model.State,
                ApartmentNumber = model.ApartmentNumber,
                Rent            = model.Rent,
                TenantId        = model.TenantId,
                Longitude       = LocationData.geometry.location.lng.ToString(),
                Latitude        = LocationData.geometry.location.lat.ToString(),
                DateClaimed     = DateTimeOffset.Now
            };

            using (var ctx = new Landlord.Data.ApplicationDbContext())
            {
                ctx.Properties.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
Example #2
0
 public void UpdateTenant(Tenant toUpdate)
 {
     using (var ctx = new Landlord.Data.ApplicationDbContext())
     {
         ctx.Entry(toUpdate).State = EntityState.Modified;
         ctx.SaveChanges();
     }
 }
Example #3
0
 public Property GetPropertyById(int id)
 {
     using (var ctx = new Landlord.Data.ApplicationDbContext())
     {
         Property toRemove = ctx.Properties.Find(id);
         return(toRemove);
     }
 }
Example #4
0
 public void DeleteTenant(int id)
 {
     using (var ctx = new Landlord.Data.ApplicationDbContext())
     {
         Tenant toRemove = ctx.Tenants.Find(id);
         ctx.Tenants.Remove(toRemove);
         ctx.SaveChanges();
     }
 }
Example #5
0
 public Tenant GetTenantById(int id)
 {
     using (var ctx = new Landlord.Data.ApplicationDbContext())
     {
         Tenant toRemove = ctx.Tenants.Find(id);
         //ctx.Properties.Remove(toRemove);
         return(toRemove);
     }
 }
Example #6
0
 public void DeleteProperty(int id)
 {
     using (var ctx = new Landlord.Data.ApplicationDbContext())
     {
         Property toRemove = ctx.Properties.Find(id);
         ctx.Properties.Remove(toRemove);
         ctx.SaveChanges();
     }
 }
Example #7
0
        public void UpdateProperty(Property toUpdate)
        {
            Result LocationData = GetLocationData(toUpdate.Address);

            using (var ctx = new Landlord.Data.ApplicationDbContext())
            {
                toUpdate.Latitude         = LocationData.geometry.location.lat.ToString();
                toUpdate.Longitude        = LocationData.geometry.location.lng.ToString();
                ctx.Entry(toUpdate).State = EntityState.Modified;
                ctx.SaveChanges();
            }
        }
Example #8
0
        public bool CreateTenant(TenantCreate model)
        {
            var entity =
                new Tenant
            {
                OwnerId   = _ownerId,
                FirstName = model.FirstName,
                LastName  = model.LastName
            };

            using (var ctx = new Landlord.Data.ApplicationDbContext())
            {
                ctx.Tenants.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }