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); } }
public void UpdateTenant(Tenant toUpdate) { using (var ctx = new Landlord.Data.ApplicationDbContext()) { ctx.Entry(toUpdate).State = EntityState.Modified; ctx.SaveChanges(); } }
public Property GetPropertyById(int id) { using (var ctx = new Landlord.Data.ApplicationDbContext()) { Property toRemove = ctx.Properties.Find(id); return(toRemove); } }
public void DeleteTenant(int id) { using (var ctx = new Landlord.Data.ApplicationDbContext()) { Tenant toRemove = ctx.Tenants.Find(id); ctx.Tenants.Remove(toRemove); ctx.SaveChanges(); } }
public Tenant GetTenantById(int id) { using (var ctx = new Landlord.Data.ApplicationDbContext()) { Tenant toRemove = ctx.Tenants.Find(id); //ctx.Properties.Remove(toRemove); return(toRemove); } }
public void DeleteProperty(int id) { using (var ctx = new Landlord.Data.ApplicationDbContext()) { Property toRemove = ctx.Properties.Find(id); ctx.Properties.Remove(toRemove); ctx.SaveChanges(); } }
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(); } }
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); } }