public ActionResult ViewPayments(int id)
        {
            List <BGBC.Web.Models.AllPropertiesAndTenant> allPropertiesAndTenant = new List <Models.AllPropertiesAndTenant>();

            try
            {
                Property p = _propertyRepo.Get(id);
                BGBC.Web.Models.AllPropertiesAndTenant propertiesTenant = new Models.AllPropertiesAndTenant();
                ViewBag.PropertyID = p.PropertyID;
                ViewBag.Name       = p.Name;
                ViewBag.Address    = p.Address;
                ViewBag.Address2   = p.Address2;
                ViewBag.City       = p.City;
                ViewBag.State      = p.State;
                ViewBag.Zip        = p.Zip;

                propertiesTenant.tenantRentPay = new List <Models.TenantRentPay>();
                foreach (var t in p.Tenants)
                {
                    BGBC.Web.Models.TenantRentPay tenantRentPay = new BGBC.Web.Models.TenantRentPay();
                    tenantRentPay.tname       = t.User.FirstName;
                    tenantRentPay.RentPayment = BGBCFunctions.RentPayments().Where(x => x.TenantUserID == t.User.UserID).ToList();
                    propertiesTenant.tenantRentPay.Add(tenantRentPay);
                }
                allPropertiesAndTenant.Add(propertiesTenant);
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
            }
            return(View(allPropertiesAndTenant));
        }
Exemple #2
0
        public ActionResult AllPropertiesAndTenant()
        {
            List <BGBC.Web.Models.AllPropertiesAndTenant> allPropertiesAndTenant = new List <Models.AllPropertiesAndTenant>();
            List <Property> property = _pro.GetRef(((BGBC.Core.CustomPrincipal)(User)).UserId);

            foreach (var p in property)
            {
                BGBC.Web.Models.AllPropertiesAndTenant allProps = new Models.AllPropertiesAndTenant();
                allProps.Pname         = p.Name;
                allProps.tenantRentPay = new List <Models.TenantRentPay>();
                foreach (var t in p.Tenants)
                {
                    BGBC.Web.Models.TenantRentPay tRentPay = new BGBC.Web.Models.TenantRentPay();
                    tRentPay.tname       = t.User.FirstName + " " + t.User.LastName;
                    tRentPay.RentPayment = BGBCFunctions.RentPayments().Where(x => x.TenantUserID == t.User.UserID).OrderByDescending(d => d.TransDate).Take(5).ToList();
                    allProps.tenantRentPay.Add(tRentPay);
                }
                allPropertiesAndTenant.Add(allProps);
            }

            return(View(allPropertiesAndTenant));
        }