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)); }
public ActionResult TopNavBar() { var user = User.Identity.Name; var login = AccountService.GetLoginByEmail(user); if (login == null) { return(View("Error")); } var userRoles = AccountService.GetUserRolesbyEmail(user); var isOwner = PropertyOwnerService.IsLoginOwner(login); var isTenant = TenantService.IsLoginATenant(login); var isServiceSupplier = CompanyService.IsServiceSupplier(login); var isAdmin = AccountService.IsAdmin(login); var model = new SideBarViewModel { Roles = userRoles, IsPropertyOwner = userRoles.Contains(4), IsTenant = userRoles.Contains(5), IsServiceSupplier = userRoles.Contains(6), IsAdmin = userRoles.Contains(2), IsPropManager = userRoles.Contains(3) }; return(PartialView(model)); }
public async Task <ActionResult> AcceptTenantRequest(int requestId) { var user = User.Identity.Name; var login = AccountService.GetLoginByEmail(user); var res = await PropertyOwnerService.AcceptTenantRequest(requestId, login); return(Json(new { Success = res.IsSuccess, Msg = res.ErrorMessage })); }
public ActionResult RentalPaymentTracking() { var user = User.Identity.Name; var login = AccountService.GetLoginByEmail(user); var paymentTrackings = PropertyOwnerService.GetRenalPaymentTracking(login); return(View(paymentTrackings)); }
public ActionResult MyRequests(POMyRequestsSearchModel model) { var user = User.Identity.Name; var login = AccountService.GetLoginByEmail(user); if (String.IsNullOrWhiteSpace(model.SortOrder)) { model.SortOrder = "Latest First"; } if (model.RequestStatus == null) { model.RequestStatus = PropertyRequestStatus.Submitted; } var res = PropertyOwnerService.GetMyRequests(model, login); model.PagedInput = new PagedInput { ActionName = "MyRequests", ControllerName = "Property", PagedLinkValues = new RouteValueDictionary(new { SortOrder = model.SortOrder, SearchString = model.SearchString, ReturnUrl = model.ReturnUrl, RequestStatus = model.RequestStatus.ToString() }), }; model.InputValues = new List <SearchInput>() { new SearchInput { Name = "RequestStatus", Value = model.RequestStatus.ToString() } }; var rvr = new RouteValueDictionary(new { SearchString = model.SearchString, ReturnUrl = model.ReturnUrl, RequestStatus = model.RequestStatus.ToString() }); var sortOrders = new List <SortOrderModel>(); sortOrders.Add(new SortOrderModel { SortOrder = "Latest First", ActionName = "MyRequests", RouteValues = rvr.AddRouteValue("SortOrder", "Latest First") }); sortOrders.Add(new SortOrderModel { SortOrder = "Earliest First", ActionName = "MyRequests", RouteValues = rvr.AddRouteValue("SortOrder", "Earliest First") }); model.SortOrders = sortOrders; model.SearchCount = res.SearchCount; if (String.IsNullOrWhiteSpace(model.SearchString)) { model.Page = 1; } model.PageCount = res.Items.PageCount; model.Items = res.Items; model.EditUrl = "/PropertyOwners/Property/EditMyRequest"; model.DeleteUrl = "/PropertyOwners/Property/DeleteMyRequest"; TempData["CurrentLink"] = "POMyRequests"; return(View(model)); }
// 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()); }
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()); }
public ActionResult Dashboard() { var user = User.Identity.Name; //var gp = User as GenericPrincipal; //var roles = gp.Claims // .Where(c => c.Type == ClaimTypes.Role) // .Select(c => c.Value); var login = AccountService.GetLoginByEmail(user); var isOwner = PropertyOwnerService.IsLoginOwner(login); var isTenant = TenantService.IsLoginATenant(login); var isServiceSupplier = CompanyService.IsServiceSupplier(login); var isPropertyManager = PropertyOwnerService.IsLoginPropertyManager(login); var tenant = db.Tenant.FirstOrDefault(x => x.Id == login.Id); ViewBag.IsOwner = false; ViewBag.IsTenant = false; ViewBag.IsServiceSupplier = false; ViewBag.IsPropertyManager = false; if (isOwner) { ViewBag.isOwner = true; } if (isTenant) { ViewBag.IsTenant = true; if (tenant != null && tenant.IsCompletedPersonalProfile == false) { return(RedirectToAction("Onboarding", "Home", new { area = "Tenants" })); } } if (isServiceSupplier) { ViewBag.IsServiceSupplier = true; } if (isPropertyManager) { ViewBag.IsPropertyManager = true; } //if (tenant.IsCompletedPersonalProfile == false) //{ // return RedirectToAction("Onboarding", "Home", new { area = "Tenants" }); //} TempData["CurrentLink"] = "Dashboard"; return(View()); }
public ActionResult Edit(PropertyModel model) { var user = User.Identity.Name; var login = AccountService.GetLoginByEmail(user); if (String.IsNullOrEmpty(user)) { return(Json(new { Success = false })); } var files = Request.Files; var result = PropertyOwnerService.EditProperty(model, files, login); return(Json(new { Success = result.IsSuccess, Message = result.ErrorMessage, })); }
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)); }
public ActionResult SideNavBar() { var user = User.Identity.Name; var login = AccountService.GetLoginByEmail(user); var userRoles = AccountService.GetUserRolesbyEmail(user); var isOwner = PropertyOwnerService.IsLoginOwner(login); var isTenant = TenantService.IsLoginATenant(login); var isServiceSupplier = CompanyService.IsServiceSupplier(login); var isAdmin = AccountService.IsAdmin(login); var model = new SideBarViewModel { Roles = userRoles, IsPropertyOwner = isOwner, IsTenant = isTenant, IsServiceSupplier = isServiceSupplier, IsAdmin = isAdmin }; return(PartialView(model)); }
public ActionResult Dashboard() { var user = User.Identity.Name; //var gp = User as GenericPrincipal; //var roles = gp.Claims // .Where(c => c.Type == ClaimTypes.Role) // .Select(c => c.Value); var login = AccountService.GetLoginByEmail(user); var isOwner = PropertyOwnerService.IsLoginOwner(login); var isTenant = TenantService.IsLoginATenant(login); var isServiceSupplier = CompanyService.IsServiceSupplier(login); var isPropertyManager = PropertyOwnerService.IsLoginPropertyManager(login); ViewBag.IsOwner = false; ViewBag.IsTenant = false; ViewBag.IsServiceSupplier = false; ViewBag.IsPropertyManager = false; if (isOwner) { ViewBag.isOwner = true; } if (isTenant) { ViewBag.IsTenant = true; } if (isServiceSupplier) { ViewBag.IsServiceSupplier = true; } if (isPropertyManager) { ViewBag.IsPropertyManager = true; } TempData["CurrentLink"] = "Dashboard;"; return(View()); }
public JsonResult UpdateFinance(FinancialModel model) { var status = true; decimal actualTotalRepayment = 0; var message = "Record added successfully"; var data = model; // AddTenantToPropertyModel tenant = new AddTenantToPropertyModel(); //*********** AddNewProperty var user = User.Identity.Name; var login = AccountService.GetLoginByEmail(user); //var newProp = PropertyOwnerService.AddOnboardProperty(login, model); ////*********** AddRepayments var newRepayment = new PropertyRepayment(); newRepayment = PropertyOwnerService.AddOnboardRepayment(login, model.Repayments, model.PropId); decimal _totalRepayment = 0; int _nosWeeks = 0; int _nosFortnights = 0; int _nosMonthly = 0; if (newRepayment != null) { foreach (Service.Models.RepaymentViewModel repayment in model.Repayments) { switch (repayment.FrequencyType) { case 1: // Weekly // find the nos of weeks in datediff(StartDate, EndDate) _nosWeeks = ((newRepayment.EndDate - newRepayment.StartDate) ?? TimeSpan.Zero).Days / 7; // _totalAmount = nos weeks * amount _totalRepayment = _nosWeeks * newRepayment.Amount; break; case 2: // Fortnightly // find the nos of Fortnights in datediff(StartDate, EndDate) _nosFortnights = ((newRepayment.EndDate - newRepayment.StartDate) ?? TimeSpan.Zero).Days / 14; // _totalAmount = nos weeks * amount _totalRepayment = _nosFortnights * newRepayment.Amount; break; case 3: //Monthly // find the nos of Monthls in datediff(StartDate, EndDate) _nosMonthly = ((newRepayment.EndDate - newRepayment.StartDate) ?? TimeSpan.Zero).Days / 30; _totalRepayment = _nosMonthly * newRepayment.Amount; // _totalAmount = nos Monthls * amount break; } actualTotalRepayment += _totalRepayment; } //*****AddExpenses var newExpense = new PropertyExpense(); newExpense = PropertyOwnerService.AddOnboardExpense(login, model.Expenses, model.PropId); //******AddFinancial var newFinancial = new PropertyFinance(); newFinancial = PropertyOwnerService.AddPropertyFinance(login, model, model.PropId, actualTotalRepayment); var newRentalPayment = new PropertyRentalPayment(); // newRentalPayment = PropertyOwnerService.AddOnboardRentalPayment(login, model.RentalPayments, model.PropId); } return(Json(new { success = status, message = message })); }
public async Task <ActionResult> AddProperty(PropertyMyOnboardModel model) { var status = true; var message = "Record added successfully"; var data = model; AddTenantToPropertyModel tenant = new AddTenantToPropertyModel(); //*********** AddNewProperty var user = User.Identity.Name; var login = AccountService.GetLoginByEmail(user); var newProp = PropertyOwnerService.AddOnboardProperty(login, model); var address = model.Address.ToAddressString(); var ownerPerson = AccountService.GetPersonByLoginId(login.Id); ////*********** AddRepayments var newRepayment = new PropertyRepayment(); if (newProp == null) { return(Json(new { Success = false, message = "Cannot find the property!" })); } else { newRepayment = PropertyOwnerService.AddOnboardRepayment(login, model.Repayments, newProp.Id); decimal _totalRepayment = 0; int _nosWeeks = 0; int _nosFortnights = 0; int _nosMonthly = 0; if (newRepayment != null) { foreach (Service.Models.RepaymentViewModel repayment in model.Repayments) { switch (repayment.FrequencyType) { case 1: // Weekly // find the nos of weeks in datediff(StartDate, EndDate) _nosWeeks = ((newRepayment.EndDate - newRepayment.StartDate) ?? TimeSpan.Zero).Days / 7; // _totalAmount = nos weeks * amount _totalRepayment = _nosWeeks * newRepayment.Amount; break; case 2: // Fortnightly // find the nos of Fortnights in datediff(StartDate, EndDate) _nosFortnights = ((newRepayment.EndDate - newRepayment.StartDate) ?? TimeSpan.Zero).Days / 14; // _totalAmount = nos weeks * amount _totalRepayment = _nosFortnights * newRepayment.Amount; break; case 3: //Monthly // find the nos of Monthls in datediff(StartDate, EndDate) _nosMonthly = ((newRepayment.EndDate - newRepayment.StartDate) ?? TimeSpan.Zero).Days / 30; _totalRepayment = _nosMonthly * newRepayment.Amount; // _totalAmount = nos Monthls * amount break; } actualTotalRepayment += _totalRepayment; } } ////*****AddExpenses //var newExpense = new PropertyExpense(); //newExpense = PropertyOwnerService.AddOnboardExpense(login, model.Expenses, newProp.Id); //******AddFinancial var newFinancial = new PropertyFinance(); newFinancial = PropertyOwnerService.AddOnboardFinance(login, model, newProp.Id, actualTotalRepayment); //return Json( new { Success = true , PropertyId = newProp.Id}); if (!model.IsOwnerOccupied) { var ten = AccountService.GetExistingLogin(model.TenantToPropertyModel.TenantEmail); if (ten == null) { var sendEmail = false; string temPass = null; /// CREATE AN ACCOUNT AND SEND EMAIL TO TENANT TO ACTIVATE AND RESET ACCOUNT temPass = UtilService.GeneraterRandomKey(8); var createRes = AccountService.CreateTenantAccount(model.TenantToPropertyModel, login, temPass); if (createRes.IsSuccess) { ten = createRes.NewObject as Login; sendEmail = true; } if (sendEmail && temPass != null) { var per = AccountService.GetPersonByLoginId(ten.Id); await EmailService.SendCreateAccountToTenantSendgrid(per, model.TenantToPropertyModel.TenantEmail, temPass, ownerPerson, ten.EmailConfirmationToken, address); } } else { if (!ten.IsActive) { var resultTenantActive = PropertyService.ActivateTenant(login, ten.Id); if (resultTenantActive.IsSuccess) { // SEND EMAIL INTIMATING THAT ACCOUNT HAS BEEN ACTIVATED BY THE OWNER //await SendActivationEmailToTenant(model); } else { return(Json(new { Sucess = false, redirect = "Redirect", url = Url.Action("Index", "PropertyOwners") })); } } } var person = AccountService.GetPersonByLoginId(ten.Id); var result = PropertyService.AddTenantToProperty(login, person.Id, newProp.Id, model.TenantToPropertyModel.StartDate, model.TenantToPropertyModel.EndDate, model.TenantToPropertyModel.PaymentFrequencyId, model.TenantToPropertyModel.PaymentAmount); if (result.IsSuccess) { string url = UtilService.UrlGenerator(System.Web.HttpContext.Current.Request, "Tenant/Home/MyRentals"); SendGridEmailModel mail = new SendGridEmailModel { RecipentName = model.TenantToPropertyModel.FirstName, ButtonText = "", ButtonUrl = url, RecipentEmail = model.TenantToPropertyModel.TenantEmail, OwnerName = ownerPerson.FirstName, Address = address, }; await EmailService.SendEmailWithSendGrid(EmailType.OwnerAddTenantEmail, mail); return(Json(new { Sucess = true, Msg = "Added!", result = "Redirect", url = Url.Action("Index", "PropertyOwners") })); } else { return(Json(new { Sucess = false, Msg = result.ErrorMessage, redirect = "Redirect", url = Url.Action("Index", "PropertyOwners") })); } } } return(Json(new { success = status, message = message, data = tenant })); }
public async Task <JsonResult> AddNewProperty(PropertyMyOnboardModel model) { var files = Request.Files; var status = true; var message = "Record added successfully"; var data = model; AddTenantToPropertyModel tenant = new AddTenantToPropertyModel(); var user = User.Identity.Name; var login = AccountService.GetLoginByEmail(user); var newProp = PropertyOwnerService.AddOnboardProperty(login, model); var newRepayment = new PropertyRepayment(); if (newProp == null) { return(Json(new { Success = false, message = "Cannot add the property!" })); } else { newRepayment = PropertyOwnerService.AddOnboardRepayment(login, model.Repayments, newProp.Id); decimal _totalRepayment = 0; int _nosWeeks = 0; int _nosFortnights = 0; int _nosMonthly = 0; if (newRepayment != null) { foreach (Service.Models.RepaymentViewModel repayment in model.Repayments) { switch (repayment.FrequencyType) { case 1: // Weekly // find the nos of weeks in datediff(StartDate, EndDate) _nosWeeks = ((newRepayment.EndDate - newRepayment.StartDate) ?? TimeSpan.Zero).Days / 7; // _totalAmount = nos weeks * amount _totalRepayment = _nosWeeks * newRepayment.Amount; break; case 2: // Fortnightly // find the nos of Fortnights in datediff(StartDate, EndDate) _nosFortnights = ((newRepayment.EndDate - newRepayment.StartDate) ?? TimeSpan.Zero).Days / 14; // _totalAmount = nos weeks * amount _totalRepayment = _nosFortnights * newRepayment.Amount; break; case 3: //Monthly // find the nos of Monthls in datediff(StartDate, EndDate) _nosMonthly = ((newRepayment.EndDate - newRepayment.StartDate) ?? TimeSpan.Zero).Days / 30; _totalRepayment = _nosMonthly * newRepayment.Amount; // _totalAmount = nos Monthls * amount break; } actualTotalRepayment += _totalRepayment; } } //*****AddExpenses var newExpense = new PropertyExpense(); newExpense = PropertyOwnerService.AddOnboardExpense(login, model.Expenses, newProp.Id); //******AddFinancial var newFinancial = new PropertyFinance(); newFinancial = PropertyOwnerService.AddOnboardFinance(login, model, newProp.Id, actualTotalRepayment); var ownerPerson = AccountService.GetPersonByLoginId(login.Id); if (!model.IsOwnerOccupied) { var ten = AccountService.GetExistingLogin(model.TenantToPropertyModel.TenantEmail); if (ten == null) { var sendEmail = false; var temPass = UtilService.GeneraterRandomKey(8); var createRes = AccountService.CreateTenantAccount(model.TenantToPropertyModel, login, temPass); if (createRes.IsSuccess) { ten = createRes.NewObject as Login; sendEmail = true; } if (sendEmail) { var emailRes = await EmailService.SendCreateAccountToTenant(model, temPass, ownerPerson); } else { return(Json(new { Success = false, NewPropId = newProp.Id })); } //return Json(new { Success = false, NewPropId = newProp.Id, Todo = "Send email", ErrorMsg = "Cannot find person in login table!" }); } else // ten not null { if (!ten.IsActive) { var resultTenantActive = PropertyService.ActivateTenant(login, ten.Id); if (resultTenantActive.IsSuccess) { await EmailService.SendActivationEmailToTenant(model, ownerPerson); } } } var person = AccountService.GetPersonByLoginId(ten.Id); //var result = PropertyService.AddTenantToProperty(login, person.Id, newProp.Id, model.TenantToPropertyModel.StartDate, // model.TenantToPropertyModel.EndDate, model.TenantToPropertyModel.PaymentFrequencyId, model.TenantToPropertyModel.PaymentAmount); model.TenantToPropertyModel.Liabilities = model.LiabilityValues; model.TenantToPropertyModel.PropertyId = newProp.Id; var result = PropertyService.AddTenant(login, ten.Id, model.TenantToPropertyModel); if (result.IsSuccess) { return(Json(new { Sucess = true, Msg = "Added!", NewPropId = newProp.Id, result = "Redirect", url = Url.Action("Index", "PropertyOwners") })); } else { return(Json(new { Sucess = false, NewPropId = newProp.Id, Msg = result.ErrorMessage, redirect = "Redirect", url = Url.Action("Index", "PropertyOwners") })); } } } return(Json(new { Success = status, NewPropId = newProp.Id, message = message, data = tenant })); }
public PropertyOwnerController(PropertyOwnerService propertyOwnerService) { _propertyOwnerService = propertyOwnerService; }
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)); }