// GET: UserTypeModels
        public ActionResult Index()
        {
            UserTypeBinder userBinder = new UserTypeBinder();
            ICollection <UserTypeModel> userTypeModelList = userBinder.Bind(db.UserType.ToList());

            return(View(userTypeModelList));
        }
        public ActionResult Create([Bind(Include = "Id,UserTypeCode")] UserTypeModel userTypeModel)
        {
            if (ModelState.IsValid)
            {
                UserTypeBinder userTypeBinder = new UserTypeBinder();
                UserType       userType       = userTypeBinder.Bind(userTypeModel);
                db.UserType.Add(userType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(userTypeModel));
        }
Ejemplo n.º 3
0
        public void TypeCanBeResolvedFromParent_ResolvesType()
        {
            // Arrange
            var binder       = new UserTypeBinder();
            var resolvedType = Substitute.For <INamedTypeSymbol>();
            var field        = Substitute.For <IField>();

            field.ResolveType("UserType").Returns(resolvedType);

            var node = ParserInput
                       .FromString("UserType")
                       .ParseInput(parser => parser.userType());

            // Act
            var result = binder.Bind <UserType>(node, field);

            // Assert
            Assert.Same(resolvedType, result.Definition);
        }