Exemplo n.º 1
0
        public IHttpActionResult PostUserRoleInt(UserRoleInt userRoleInt)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _uow.UserRolesInt.Add(userRoleInt);
            _uow.Commit();

            return(CreatedAtRoute("DefaultApi", new { id = userRoleInt.RoleId }, userRoleInt));
        }
        public ActionResult Create([Bind(Include = "UserId,RoleId")] UserRoleInt userRole)
        {
            if (ModelState.IsValid)
            {
                _uow.GetRepository <IUserRoleIntRepository>().Add(userRole);
                _uow.Commit();
                return(RedirectToAction("Index"));
            }

            ViewBag.RoleId = new SelectList(_uow.GetRepository <IRoleIntRepository>().All, "Id", "Name", userRole.RoleId);
            ViewBag.UserId = new SelectList(_uow.GetRepository <IUserIntRepository>().All, "Id", "Email", userRole.UserId);
            return(View(userRole));
        }