public UserType(UserGroupFacade userGroupFacade, UserMarkFacade userMarkFacade, UserRoleFacade userRoleFacade, GroupFacade groupFacade, GroupSubjectFacade groupSubjectFacade) { Field(x => x.Id); Field <StringGraphType>("login", resolve: context => context.Source.Login); Field <StringGraphType>("password", resolve: context => context.Source.Password); Field <StringGraphType>("firstName", resolve: context => context.Source.FirstName); Field <StringGraphType>("lastName", resolve: context => context.Source.LastName); Field <StringGraphType>("secondName", resolve: context => context.Source.SecondName); Field <ListGraphType <GroupType> >("group", resolve: context => { return(userGroupFacade.GetByUserId(context.Source.Id, groupFacade)); } ); Field <ListGraphType <UserMarkType> >("userMarks", resolve: context => userMarkFacade.GetByUserId(context.Source.Id) ); Field <UserMarkType>("userMark", arguments: new QueryArguments(new QueryArgument <IntGraphType> { Name = "id" }), resolve: context => userMarkFacade.GetById(context.GetArgument <int>("id"))); Field <UserRoleType>( "userRole", resolve: context => userRoleFacade.GetById(context.Source.UserRoleId) ); }
public async Task <IActionResult> Create(UserRoleModel applicationUserRole) { if (ModelState.IsValid) { var appUserRole = await _userRoleFacade.GetById(applicationUserRole.UserId); if (appUserRole == null) { await _userRoleFacade.Create(applicationUserRole); return(RedirectToAction(nameof(Index))); } } ViewData["RoleId"] = new SelectList(await _roleFacade.GetAll(), "Id", "Name", applicationUserRole.RoleId); ViewData["UserId"] = new SelectList(await _userFacade.GetAll(), "Id", "UserName", applicationUserRole.UserId); return(View(applicationUserRole)); }
private void AddUserRoleQueries(UserRoleFacade userRoleFacade) { Field <ListGraphType <UserRoleType> >( "allUserRoles", resolve: context => userRoleFacade.GetAll() ); Field <UserRoleType>("userRole", arguments: new QueryArguments(new QueryArgument <IntGraphType> { Name = "id" }), resolve: context => { var id = context.GetArgument <int?>("id"); return(id != null ? (userRoleFacade.GetById((int)id)) : null); } ); }