public ActionResult TenantDashboard(int?steps) { var user = User.Identity.Name; var login = AccountService.GetLoginByEmail(user); var props = db.TenantProperty.Where(x => x.TenantId == login.Id && (x.IsActive ?? true)); var propIds = props.Select(x => x.PropertyId); //ApplicationStatusId {1 : Applied, 2 : Accepted, 3: Declined} var rentApps = db.RentalApplication.Where(x => x.PersonId == login.Id && x.IsActive); var newApps = rentApps.Where(x => x.ApplicationStatusId == 1 && !(x.IsViewedByOwner ?? false)).Count(); var acceptedApps = rentApps.Where(x => x.ApplicationStatusId == 2).Count(); var pendingApps = rentApps.Where(x => x.ApplicationStatusId == 1 && (x.IsViewedByOwner ?? false)).Count(); var declinedApps = rentApps.Where(x => x.ApplicationStatusId == 3).Count(); // Get Landlord request's statistics var landlordreqs = db.PropertyRequest.Where(x => propIds.Contains(x.Property.Id) && x.IsActive && !x.ToOwner && x.ToTenant); var newLandlordRequests = landlordreqs.Where(x => x.RequestStatusId == 1).Count(); var acceptedLandlordRequests = landlordreqs.Where(x => x.RequestStatusId == 2).Count(); var rejectedLandlordRequests = landlordreqs.Where(x => x.RequestStatusId == 5).Count(); var tenRequests = db.PropertyRequest.Where(x => propIds.Contains(x.Property.Id) && x.IsActive && x.ToOwner && !x.ToTenant); var newRequests = tenRequests.Where(x => !x.IsViewed).Count(); var acceptedRequests = tenRequests.Where(x => x.RequestStatusId == 2).Count(); var model = new TenantDashBoardModel { TenantRentalDashboardData = TenantService.GetTenantRentals(login.Id), }; model.IntroSteps = steps.HasValue ? steps.Value : 0; return(PartialView("_TenantDashboard", model)); }
public ActionResult Dashboard() { var user = User.Identity.Name; var login = AccountService.GetLoginByEmail(user); var props = db.TenantProperty.Where(x => x.TenantId == login.Id && (x.IsActive ?? true)); var propIds = props.Select(x => x.PropertyId); //ApplicationStatusId {1 : Applied, 2 : Accepted, 3: Declined} var rentApps = db.RentalApplication.Where(x => x.PersonId == login.Id && x.IsActive); var newApps = rentApps.Where(x => x.ApplicationStatusId == 1 && !(x.IsViewedByOwner ?? false)).Count(); var acceptedApps = rentApps.Where(x => x.ApplicationStatusId == 2).Count(); var pendingApps = rentApps.Where(x => x.ApplicationStatusId == 1 && (x.IsViewedByOwner ?? false)).Count(); var declinedApps = rentApps.Where(x => x.ApplicationStatusId == 3).Count(); var landlordreqs = db.PropertyRequest.Where(x => propIds.Contains(x.Property.Id) && x.IsActive && !x.ToOwner && x.ToTenant); var newLandlordReqs = landlordreqs.Where(x => !x.IsViewed).Count(); var viewedLandLordReqs = landlordreqs.Where(x => x.IsViewed).Count(); var tenRequests = db.PropertyRequest.Where(x => propIds.Contains(x.Property.Id) && x.IsActive && x.ToOwner && !x.ToTenant);//Total var newRequests = tenRequests.Where(x => x.RequestStatusId == 1).Count(); var acceptedRequests = tenRequests.Where(x => x.RequestStatusId == 2).Count(); var rejRequests = tenRequests.Where(x => x.RequestStatusId == 5).Count(); var model = new TenantDashBoardModel { TenantRentalDashboardData = TenantService.GetRentalInfo(login.Id), RentAppsDashboardData = new TenantRentAppDashboardModel { NewItems = newApps, Accepted = acceptedApps, //Pending = pendingApps, Rejected = declinedApps, }, LandLordRequestDashboardData = new LandLordRequestDashboardModel { }, TenantRequestDashboardData = new TenantRequestDashboardModel { Current = newRequests, Accepted = acceptedRequests, Rejected = rejRequests //Pending = tenRequests.Count() - (newRequests + acceptedRequests), } }; return(View(model)); }