Example #1
0
        public ActionResult EditTenantInProperty(int tenantId, int propId, string returnUrl)
        {
            var freqs    = PropertyOwnerService.GetAllPaymentFrequencies();
            var user     = User.Identity.Name;
            var id       = AccountService.GetLoginByEmail(user).Id;
            var property = PropertyService.GetPropertyById(propId);

            ViewBag.Frequencies = freqs;
            ViewBag.ReturnUrl   = returnUrl;

            var address = PropertyService.GetAddressById(property.AddressId);

            if (address != null)
            {
                if (address.Street != "" && address.Suburb != "" && address.City != "")
                {
                    var propertyVm = new PropertyViewModel
                    {
                        Id            = property.Id,
                        Name          = property.Name,
                        AddressString = address.Number + " " + address.Street + ", " + address.Suburb + ", " + address.City + ", " + address.PostCode
                    };

                    ViewBag.Property = propertyVm;
                }
            }

            var propertyTenant = PropertyService.GetTenantInProperty(tenantId, propId);

            return(View(propertyTenant));
        }
Example #2
0
        // GET: PropertyOwners/Onboarding
        public ActionResult Index()
        {
            var freqs                  = PropertyOwnerService.GetAllPaymentFrequencies();
            var propertyTypes          = PropertyService.GetAllProprtyTypes();
            var propertyHomeValueTypes = PropertyService.GetAllProprtyHomeValueTypes();

            ViewBag.Frequencies            = freqs;
            ViewBag.PropertyTypes          = propertyTypes;
            ViewBag.PropertyHomeValueTypes = propertyHomeValueTypes;
            return(View());
        }
Example #3
0
        public ActionResult AddNewProperty()
        {
            var freqs                  = PropertyOwnerService.GetAllPaymentFrequencies();
            var propertyTypes          = PropertyService.GetAllProprtyTypes();
            var propertyHomeValueTypes = PropertyService.GetAllProprtyHomeValueTypes();

            ViewBag.Frequencies            = freqs;
            ViewBag.PropertyTypes          = propertyTypes;
            ViewBag.PropertyHomeValueTypes = propertyHomeValueTypes;
            ViewBag.PathAndQuery           = HttpContext.Request.UrlReferrer.PathAndQuery;
            TempData["CurrentLink"]        = "Properties";
            return(View());
        }
Example #4
0
        public ActionResult AddTenantDashBoard(int?propId, string returnUrl)
        {
            var freqs = PropertyOwnerService.GetAllPaymentFrequencies();

            ViewBag.Frequencies = freqs;
            var user       = User.Identity.Name;
            var login      = AccountService.GetLoginByEmail(user);
            var properties = PropertyService.GetPropertiesAndAddress(login.Id, propId).ToList();

            properties.ForEach(x => x.AddressString = x.Address.ToAddressString());
            var model = new PropDataModel
            {
                ReturnUrl  = returnUrl,
                Properties = properties
            };

            ViewBag.ReturnUrl = returnUrl ?? "/PropertyOwners/Home/Dashboard";
            return(View(model));
        }
Example #5
0
        public ActionResult Index(POPropSearchModel model)
        {
            var user  = User.Identity.Name;
            var login = AccountService.GetLoginByEmail(user);

            if (String.IsNullOrWhiteSpace(model.SortOrder))
            {
                model.SortOrder = "Latest Date";
            }
            var prop = db.OwnerProperty.Where(x => x.PropertyId == 2678).First();
            var data = db.OwnerProperty.Where(x => x.Person.Login.UserName == User.Identity.Name && x.Property.IsActive)
                       .Select(x => new PropViewModel {
                Model = new PropertyModel {
                    Id               = x.PropertyId,
                    PropertyTypeId   = x.Property.PropertyTypeId,
                    Name             = x.Property.Name,
                    Description      = x.Property.Description,
                    Bedroom          = x.Property.Bedroom,
                    Bathroom         = x.Property.Bathroom,
                    LandSqm          = x.Property.LandSqm,
                    ParkingSpace     = x.Property.ParkingSpace,
                    FloorArea        = x.Property.FloorArea,
                    TargetRent       = x.Property.TargetRent,
                    TargetRentTypeId = x.Property.TargetRentTypeId,
                    YearBuilt        = x.Property.YearBuilt,
                    IsOwnerOccupied  = x.Property.IsOwnerOccupied,
                    Address          = new AddressViewModel
                    {
                        AddressId = x.Property.Address.AddressId,
                        CountryId = x.Property.Address.CountryId,
                        Number    = x.Property.Address.Number.Replace(" ", ""),
                        Street    = x.Property.Address.Street.Trim(),
                        City      = x.Property.Address.City.Trim(),
                        Suburb    = x.Property.Address.Suburb.Trim() ?? "",
                        PostCode  = x.Property.Address.PostCode.Replace(" ", ""),
                        Latitude  = x.Property.Address.Lat,
                        Longitude = x.Property.Address.Lng,
                    },
                    MediaFiles = x.Property.PropertyMedia.Select(y => new MediaModel {
                        Id = y.Id, NewFileName = y.NewFileName, OldFileName = y.OldFileName
                    }).ToList()
                },
                PropertyTypeName = x.Property.PropertyType.Name,
                CreatedOn        = x.Property.CreatedOn,
                PurchasePrice    = x.Property.PropertyFinance.PurchasePrice,
                CurrentHomeValue = x.Property.PropertyFinance.CurrentHomeValue,
                TenantCount      = x.Property.TenantProperty.Where(y => y.IsActive ?? true).Count(),
            });
            var allItems = data.OrderByDescending(x => x.CreatedOn).ToPagedList(model.Page, 10);

            switch (model.SortOrder)
            {
            case "Name":
                data = data.OrderBy(s => s.Model.Name);
                break;

            case "Name(Desc)":
                data = data.OrderByDescending(s => s.Model.Name);
                break;

            case "Latest Date":
                data = data.OrderByDescending(s => s.CreatedOn);
                break;

            case "Earliest Date":
                data = data.OrderBy(s => s.CreatedOn);
                break;

            default:
                data = data.OrderByDescending(s => s.CreatedOn);
                break;
            }
            if (!String.IsNullOrWhiteSpace(model.SearchString))
            {
                SearchTool searchTool   = new SearchTool();
                int        searchType   = searchTool.CheckDisplayType(model.SearchString);
                string     formatString = searchTool.ConvertString(model.SearchString);
                switch (searchType)
                {
                case 1:
                    data = data.Where(x => x.Model.Name.ToLower().EndsWith(formatString) ||
                                      x.Model.Address.City.ToLower().EndsWith(formatString) ||
                                      x.Model.Address.Suburb.ToLower().EndsWith(formatString));
                    break;

                case 2:
                    data = data.Where(x => x.Model.Name.ToLower().StartsWith(formatString) ||
                                      x.Model.Address.City.ToLower().StartsWith(formatString) ||
                                      x.Model.Address.Suburb.ToLower().StartsWith(formatString));
                    break;

                case 3:
                    data = data.Where(x => x.Model.Name.ToLower().Contains(formatString) ||
                                      x.Model.Address.City.ToLower().Contains(formatString) ||
                                      x.Model.Address.Suburb.ToLower().Contains(formatString));
                    break;
                }
            }
            var items = data.ToPagedList(model.Page, 10);
            var count = items.Count;

            items = count == 0 ? allItems : items;
            items.ToList().ForEach(x => x.Model.MediaFiles.ForEach(y => y.InjectMediaModelViewProperties()));
            var result = new SearchResult {
                SearchCount = items.Count, Items = count == 0 ? allItems : items
            };

            model.PagedInput = new PagedInput
            {
                ActionName      = "Index",
                ControllerName  = "Home",
                PagedLinkValues = new RouteValueDictionary(new { SortOrder = model.SortOrder, SearchString = model.SearchString })
            };
            var rvr        = new RouteValueDictionary(new { SearchString = model.SearchString });
            var sortOrders = new List <SortOrderModel>();

            sortOrders.Add(new SortOrderModel {
                SortOrder = "Name", ActionName = "Index", RouteValues = rvr.AddRouteValue("SortOrder", "Name")
            });
            sortOrders.Add(new SortOrderModel {
                SortOrder = "Name(Desc)", ActionName = "Index", RouteValues = rvr.AddRouteValue("SortOrder", "Name(Desc)")
            });
            sortOrders.Add(new SortOrderModel {
                SortOrder = "Latest Date", ActionName = "Index", RouteValues = rvr.AddRouteValue("SortOrder", "Latest Date")
            });
            sortOrders.Add(new SortOrderModel {
                SortOrder = "Earliest Date", ActionName = "Index", RouteValues = rvr.AddRouteValue("SortOrder", "Earliest Date")
            });
            model.SortOrders  = sortOrders;
            model.SearchCount = result.SearchCount;
            if (String.IsNullOrWhiteSpace(model.SearchString))
            {
                model.Page = 1;
            }
            model.PageCount       = result.Items.PageCount;
            model.Items           = result.Items;
            model.EditUrl         = "/PropertyOwners/Home/Edit";
            model.DeleteUrl       = "/PropertyOwners/Home/Delete";
            model.CanListRental   = allItems.Any();
            ViewBag.Frequencies   = PropertyOwnerService.GetAllPaymentFrequencies();
            ViewBag.PropertyTypes = PropertyService.GetAllProprtyTypes();
            return(View(model));
        }