public ActionResult PODashboard()
        {
            var user           = User.Identity.Name;
            var login          = AccountService.GetLoginByEmail(user);
            var props          = PropertyService.GetAllPropertiesByOwner(login.Id);
            var totalProps     = props.Count();
            var ownerOccupied  = db.OwnerProperty.Where(x => x.OwnerId == login.Id && x.Property.IsActive && (x.Property.IsOwnerOccupied ?? false)).Count();
            var tenantOccupied = db.OwnerProperty.Where(x => x.OwnerId == login.Id && x.Property.IsActive &&
                                                        x.Property.TenantProperty.Where(y => y.IsActive ?? false).Count() > 0).Count();
            var vacant = totalProps - (ownerOccupied + tenantOccupied);

            var propIds = props.Select(x => x.Id);

            var model = new PODashBoardModel
            {
                PropDashboardData = new PropDashboardModel
                {
                    Occupied = ownerOccupied + tenantOccupied,
                    Vacant   = vacant
                },
            };

            return(PartialView("_PODashboard", model));
        }
Exemple #2
0
        public ActionResult PODashboard()
        {
            var user       = User.Identity.Name;
            var login      = AccountService.GetLoginByEmail(user);
            var props      = PropertyService.GetAllPropertiesByOwner(login.Id);
            var totalProps = props.Count();
            //var ownerOccupied = db.OwnerProperty.Where(x => x.OwnerId == login.Id && x.Property.IsActive && (x.Property.IsOwnerOccupied ?? false)).Count();
            var tenantOccupied = db.OwnerProperty.Where(x => x.OwnerId == login.Id && x.Property.IsActive &&
                                                        x.Property.TenantProperty.Where(y => y.IsActive ?? false).Count() > 0).Count();

            var vacant = totalProps - (tenantOccupied);

            var propIds      = props.Select(x => x.Id);
            var rentApps     = db.RentalApplication.Where(x => propIds.Contains(x.RentalListing.PropertyId) && x.IsActive);
            var newApps      = rentApps.Where(x => x.ApplicationStatusId == 1 && !(x.IsViewedByOwner ?? false)).Count();
            var approvedApps = rentApps.Where(x => x.ApplicationStatusId == 2).Count();
            var pendingApps  = rentApps.Where(x => (x.IsViewedByOwner ?? false) && x.ApplicationStatusId == 1).Count();
            var declinedApps = rentApps.Where(x => x.ApplicationStatusId == 3).Count();

            var jobs           = db.Job.Where(x => propIds.Contains(x.PropertyId) && x.JobStatusId != 5 && x.JobStatusId != 6);
            var newJobs        = jobs.Where(x => x.PercentDone == 0).Count();
            var progressedJobs = jobs.Where(x => x.PercentDone > 0 && x.PercentDone < 100).Count();
            var finishedJobs   = jobs.Where(x => x.PercentDone == 100).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 rejRequests      = tenRequests.Where(x => x.RequestStatusId == 5).Count();

            var jobQuotes      = db.JobQuote.Where(x => propIds.Contains(x.TenantJobRequest.PropertyId) && x.Status.ToLower() != "deleted");
            var newQuotes      = jobQuotes.Where(x => x.Status.ToLower() == "opening" && !(x.IsViewed ?? false)).Count();
            var acceptedQuotes = jobQuotes.Where(x => x.Status.ToLower() == "accepted").Count();
            var pendingQuotes  = jobQuotes.Where(x => x.Status.ToLower() == "opening" && (x.IsViewed ?? false)).Count();
            var rejectedQuotes = jobQuotes.Where(x => x.Status.ToLower() == "unsuccessful").Count();
            var model          = new PODashBoardModel
            {
                PropDashboardData = new PropDashboardModel
                {
                    Occupied = tenantOccupied,
                    Vacant   = vacant
                },
                RentAppsDashboardData = new RentAppDashboardModel
                {
                    NewItems = newApps,
                    Approved = approvedApps,
                    Pending  = pendingApps,
                    Rejected = declinedApps,
                },
                JobsDashboardData = new JobsDashboardModel
                {
                    NewItems   = newJobs,
                    InProgress = progressedJobs,
                    Resolved   = finishedJobs,
                },
                RequestDashboardData = new TenantRequestDashboardModel
                {
                    Current  = newRequests,
                    Accepted = acceptedRequests,
                    Rejected = rejRequests,
                    //Pending = tenRequests.Count() - (newRequests + acceptedRequests),
                },
                JobQuotesDashboardData = new JobQuotesDashboardModel
                {
                    NewItems = newQuotes,
                    Accepted = acceptedQuotes,
                    Pending  = pendingQuotes,
                    Rejected = rejectedQuotes
                }
            };

            return(PartialView("_PODashboard", model));
        }