コード例 #1
0
        public ActionResult ListRelatedCode(string relatedtable, string startcode, string listtype, string searchtable, bool exact = false, int max = 0)// string wstype,
        {
            PageTitle = "List Related Code";

            var model = new ListRelatedCodeViewModel();

            model.Overview = new Infrastructure.ViewModels.ContentViewModel().AddTitle("List Related Code").AddParagraph("List all related codes, dominant and subordinate, for a specified related table type. A start from dominant or subordinate code can be entered.");

            if (!string.IsNullOrEmpty(relatedtable))
            {
                model.RelatedTableType   = relatedtable;
                model.StartFromTableType = startcode;
                model.ListType           = listtype;
                //model.WsType = wstype;
                model.SearchTable = searchtable;
                model.ExactLookup = exact;
                model.MaxRows     = max;

                var results = AdwAdminService.GetRelatedCodes(model.RelatedTableType, model.StartFromTableType, GetDominantFromSearchTable(model.SearchTable), GetCurrentCodeOnlyFromListType(listtype), model.ExactLookup, model.MaxRows);

                model.Results = results.ToPageableRelatedCodeViewModel();

                if (model.Results == null || (model.Results != null && !model.Results.Any()))
                {
                    AddInformationMessage("No results returned.");
                }
            }



            return(View(model));
        }
コード例 #2
0
        public void ListRelatedCode_PostRedirectedToGet()
        {
            // Arrange
            var controller = SystemUnderTest();

            var viewModel = new ListRelatedCodeViewModel()
            {
                StartFromTableType = "A", ListType = "A", MaxRows = 1, ExactLookup = true
            };
            var codeModel = new RelatedCodeModel {
                RelatedCode = "ABCD", DominantDescription = "dominant Description", SubordinateDescription = "Sub Description"
            };
            IList <RelatedCodeModel> models = new List <RelatedCodeModel>()
            {
                codeModel
            };

            mockAdwAdminService.Setup(m => m.GetRelatedCodes(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <int>())).Returns(models);


            // Act
            var result = controller.ListRelatedCode(viewModel) as RedirectToRouteResult;


            // Assert
            Assert.IsNotNull(result, "Redirect To Route Result must not be null.");
            if (result != null)
            {
                Assert.AreEqual("ListRelatedCode", result.RouteValues["action"]);
            }
        }
コード例 #3
0
        public ActionResult ListRelatedCode(ListRelatedCodeViewModel model)
        {
            if (ModelState.IsValid)
            {
                RouteValueDictionary routeValues = new RouteValueDictionary();
                routeValues.Add("relatedtable", model.RelatedTableType);
                routeValues.Add("startcode", model.StartFromTableType);
                routeValues.Add("listtype", model.ListType);
                //routeValues.Add("wstype", model.WsType);
                routeValues.Add("searchtable", model.SearchTable);
                routeValues.Add("exact", model.ExactLookup);
                routeValues.Add("max", model.MaxRows);

                return(RedirectToAction("ListRelatedCode", routeValues));
            }

            return(View(model));
        }
コード例 #4
0
        public void ListRelatedCode_Post()
        {
            // Arrange
            var controller = SystemUnderTest();

            var viewModel = new ListRelatedCodeViewModel()
            {
            };

            controller.ModelState.AddModelError("", "SomeError");

            // Act
            var result = controller.ListRelatedCode(viewModel) as ViewResult;


            // Assert
            Assert.IsNotNull(result, "View Result must not be null.");
        }