Beispiel #1
0
 public async Task <IEnumerable <PropertyDetail> > getAllPropertyDetails()
 {
     using (var context = new PropertyManagementContext(_dbContextOptions))
     {
         return(await context.PropertyDetail.Include(x => x.PropertyImage).Include(x => x.OwnerHistory).ToListAsync());
     }
 }
Beispiel #2
0
 public async Task <PropertyDetail> getPropertyDetails(int propertyDetailId)
 {
     using (var context = new PropertyManagementContext(_dbContextOptions))
     {
         return(await context.PropertyDetail.Include(x => x.PropertyImage).Include(y => y.OwnerHistory).Where(x => x.Id == propertyDetailId).FirstOrDefaultAsync());
     }
 }
Beispiel #3
0
 public async Task <IEnumerable <OwnerHistory> > getOwnerHistory(int propertyDetailId)
 {
     using (var context = new PropertyManagementContext(_dbContextOptions))
     {
         return(await context.OwnerHistory.Where(x => x.PropertyDetailId == propertyDetailId)?.ToListAsync());
     }
 }
Beispiel #4
0
        public async Task <IEnumerable <PropertyDetail> > searchPropertyDetails(PropertySearchModel searchModel)
        {
            using (var context = new PropertyManagementContext(_dbContextOptions))
            {
                var result = context.PropertyDetail.Include(x => x.PropertyImage).Include(x => x.OwnerHistory).AsQueryable();

                if (searchModel != null)
                {
                    if (!string.IsNullOrEmpty(searchModel.OwnerName))
                    {
                        bool containsOwner = false;
                        foreach (var item in result)
                        {
                            var owners = item.OwnerHistory.Select(x => x.OwnerName);
                            foreach (var owner in owners)
                            {
                                if (owner.Contains(searchModel.OwnerName))
                                {
                                    containsOwner = true;
                                }
                            }
                            result = (!containsOwner) ? result.Where(y => y.Id != item.Id): result;
                        }
                    }
                    if (!string.IsNullOrEmpty(searchModel.Address))
                    {
                        result = result.Where(x => x.PropertyAddress.Contains(searchModel.Address));
                    }
                    if (searchModel.NumOfBedrooms.HasValue && searchModel.NumOfBedrooms.Value != 0)
                    {
                        result = result.Where(x => x.NumOfBedrooms == searchModel.NumOfBedrooms);
                    }
                    if (searchModel.NumOfBathrooms.HasValue && searchModel.NumOfBathrooms.Value != 0)
                    {
                        result = result.Where(x => x.NumOfbathrooms == searchModel.NumOfBathrooms);
                    }
                }
                return(await result?.ToListAsync());
            }
        }
 public PropertyLeasersController(PropertyManagementContext context)
 {
     _context = context;
 }
 public MaintenanceRequestsController(PropertyManagementContext context)
 {
     _context = context;
 }
 public UnitRepository()
 {
     _context = new PropertyManagementContext();
 }
 public BuildingRepository()
 {
     _context = new PropertyManagementContext();
 }
 public PaymentHistoriesController(PropertyManagementContext context)
 {
     _context = context;
 }