public ActionResult ListCode(string tabletype, string startcode, string listtype, bool exact = false, int max = 0, bool type = false) { PageTitle = "List Code"; var model = new ListCodeViewModel(); model.Overview = new Infrastructure.ViewModels.ContentViewModel().AddTitle("List Code").AddParagraph("List codes for a specified table type. If an optional code type is entered, it will be the starting value for the list or the code used when performing an exact lookup."); if (!string.IsNullOrEmpty(tabletype)) { model.TableType = tabletype; model.StartFromTableType = startcode; model.ListType = listtype; model.ExactLookup = exact; model.MaxRows = max; model.Type = type; bool currentCodesOnly = GetCurrentCodeOnlyFromListType(listtype); var results = AdwAdminService.GetListCodes(model.TableType, model.StartFromTableType, currentCodesOnly, exact, max, type); model.Results = results.ToPageableCodeTypeViewModelList(); if (model.Results == null || (model.Results != null && !model.Results.Any())) { AddInformationMessage("No results returned."); } } return(View(model)); }
public void ListCode_PostRedirectedToGet() { // Arrange var controller = SystemUnderTest(); var viewModel = new ListCodeViewModel() { StartFromTableType = "A", ListType = "A", MaxRows = 1, ExactLookup = true }; var codeModel = new CodeModel { Code = "ABCD", ShortDescription = "Short Description", Description = "LongDescription" }; IList <CodeModel> models = new List <CodeModel>() { codeModel }; mockAdwAdminService.Setup(m => m.GetListCodes(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <int>(), It.IsAny <bool>())).Returns(models); // Act var result = controller.ListCode(viewModel) as RedirectToRouteResult; // Assert Assert.IsNotNull(result, "Redirect To Route Result must not be null."); if (result != null) { Assert.AreEqual("ListCode", result.RouteValues["action"]); } }
public ActionResult ListCode(ListCodeViewModel model) { if (ModelState.IsValid) { var routeValues = new RouteValueDictionary(); routeValues.Add("tabletype", model.TableType); routeValues.Add("startcode", model.StartFromTableType); routeValues.Add("listtype", model.ListType); routeValues.Add("exact", model.ExactLookup); routeValues.Add("max", model.MaxRows); routeValues.Add("type", model.Type); return(RedirectToAction("ListCode", routeValues)); } return(View(model)); }
public void ListCode_Post() { // Arrange var controller = SystemUnderTest(); var viewModel = new ListCodeViewModel() { }; var codeModel = new CodeModel { Code = "ABCD", ShortDescription = "Short Description", Description = "LongDescription" }; controller.ModelState.AddModelError("", "SomeError"); // Act var result = controller.ListCode(viewModel) as ViewResult; // Assert Assert.IsNotNull(result, "View Result must not be null."); }