public ActionResult ListProperty(string startfrom, string startcode, string startproperty, string listtype, bool exact = false, int max = 0) { PageTitle = "List Property"; var model = new ListPropertyViewModel(); model.Overview = new Infrastructure.ViewModels.ContentViewModel().AddTitle("List Property").AddParagraph("List all codes and property types and values for a table. If a table type is entered, a code can be entered. If a type and code is entered then a property type can be entered."); if (!string.IsNullOrEmpty(startfrom) || !string.IsNullOrEmpty(startcode) || !string.IsNullOrEmpty(startproperty) || !string.IsNullOrEmpty(listtype)) { model.StartFromTableType = startfrom; model.StartFromCode = startcode; model.StartFromProperty = startproperty; model.ExactLookup = exact; model.MaxRows = max; model.ListType = listtype; var listTypeChar = '\0'; char.TryParse(listtype, out listTypeChar); var results = AdwAdminService.GetPropertyList(model.StartFromTableType, model.StartFromCode, model.StartFromProperty, listTypeChar, model.ExactLookup, model.MaxRows); model.Results = results.ToPageablePropertyViewModel(); if (model.Results == null || (model.Results != null && !model.Results.Any())) { AddInformationMessage("No results returned."); } } return(View(model)); }
public ActionResult ListProperty(ListPropertyViewModel model) { if (ModelState.IsValid) { var routeValueDictionary = new RouteValueDictionary(); routeValueDictionary.Add("startfrom", model.StartFromTableType); routeValueDictionary.Add("startcode", model.StartFromCode); routeValueDictionary.Add("startproperty", model.StartFromProperty); routeValueDictionary.Add("listtype", model.ListType); routeValueDictionary.Add("exact", model.ExactLookup); routeValueDictionary.Add("max", model.MaxRows); return(RedirectToAction("ListProperty", routeValueDictionary)); } return(View(model)); }
public void ListProperty_Post() { // Arrange var controller = SystemUnderTest(); var viewModel = new ListPropertyViewModel() { }; controller.ModelState.AddModelError("", "SomeError"); // Act var result = controller.ListProperty(viewModel) as ViewResult; // Assert Assert.IsNotNull(result, "View Result must not be null."); }
public ActionResult Save(ListPropertyViewModel model) { var property = new Property { Address = model.Address, YearBuilt = model.YearBuilt, MonthlyRent = model.MonthlyRent, ListPrice = model.ListPrice, GrossYield = model.GrossYield }; using (_context) { _context.Properties.Add(property); _context.SaveChanges(); } return(Json(model)); }
public void ListProperty_PostRedirectedToGet() { // Arrange var controller = SystemUnderTest(); var viewModel = new ListPropertyViewModel() { StartFromTableType = "A", ListType = "A", MaxRows = 1, ExactLookup = true }; // Act var result = controller.ListProperty(viewModel) as RedirectToRouteResult; // Assert Assert.IsNotNull(result, "Redirect To Route Result must not be null."); if (result != null) { Assert.AreEqual("ListProperty", result.RouteValues["action"]); } }