public async Task <IActionResult> Profile( [FromServices] IUserSevice userService, [FromServices] ISemesterService semesterService, [FromServices] IThemeService themeService, [FromServices] ISubjectService subjectService, [FromServices] IGroupService groupService, [FromServices] IMapper mapper) { var user = await userService.GetUserByIdAsync(User.GetId()); if (user == null) { return(NotFound()); } var semester = await semesterService.GetCurrentSemesterAsync(); var themes = await themeService.GetThemesAsync(new ThemeFilter { AuthorId = user.Id }); var model = mapper.Map <UserModel, ProfileViewModel>(user); if (user.GroupId.HasValue) { var subjects = await subjectService.GetSubjectsAsync(user.GroupId.Value, semester.Id); var group = await groupService.GetGroupAsync(user.GroupId.Value); model.Subjects = mapper.Map <ICollection <SubjectModel>, ICollection <SubjectViewModel> >(subjects); model.Group = mapper.Map <GroupModel, GroupViewModel>(group); } model.Themes = mapper.Map <ICollection <ThemeModel>, ICollection <ThemeViewModel> >(themes); return(Ok(model)); }
public UserController(IFreeSql freeSql, IMapper mapper, IUserSevice userSevice, ICurrentUser currentUser) { _freeSql = freeSql; _mapper = mapper; _userSevice = userSevice; _currentUser = currentUser; }
public AccountController(IConfiguration configuration, ILogger <AccountController> logger, IUserSevice userSevice, IMapper mapper) { _configuration = configuration; _logger = logger; _userSevice = userSevice; _mapper = mapper; }
public MessageBoardController(AuditBaseRepository <MessageBoard> messageBoardRepository, IMapper mapper, IHttpContextAccessor httpContextAccessor, IUserSevice userService, ICurrentUser currentUser) { _messageBoardRepository = messageBoardRepository; _mapper = mapper; _httpContextAccessor = httpContextAccessor; _userService = userService; _currentUser = currentUser; }
public UserController(IFreeSql freeSql, IMapper mapper, IUserSevice userSevice, ICurrentUser currentUser, IConfiguration configuration) { _freeSql = freeSql; _mapper = mapper; _userSevice = userSevice; _currentUser = currentUser; _configuration = configuration; }
public UserController(IFreeSql freeSql, IMapper mapper, IUserSevice userSevice, ICurrentUser currentUser, AuditBaseRepository <LinUser> userRepository) { _freeSql = freeSql; _mapper = mapper; _userSevice = userSevice; _currentUser = currentUser; _userRepository = userRepository; }
public CommentController(AuditBaseRepository <Comment> commentAuditBaseRepository, IMapper mapper, ICurrentUser currentUser, IUserSevice userService, ICommentService commentService, AuditBaseRepository <Article> articleRepository) { _commentAuditBaseRepository = commentAuditBaseRepository; _mapper = mapper; _currentUser = currentUser; _userService = userService; _commentService = commentService; _articleRepository = articleRepository; }
public ProfileController( IMapper mapper, IUserSevice userService, ISubjectService subjectService, IThemeService themeService, ISemesterService semesterService, IGroupService groupService) { Mapper = mapper; UserService = userService; SubjectService = subjectService; ThemeService = themeService; SemesterService = semesterService; GroupService = groupService; }
public async Task <IActionResult> Login([FromBody] LoginViewModel model, [FromServices] IUserSevice userService) { var user = await userService.GetUserAsync(model.Email, model.Password); if (user == null) { return(NotFound()); } var claims = new[] { new Claim(ClaimTypes.Name, user.Email), new Claim(ClaimTypes.NameIdentifier, user.Id.ToString()), new Claim(ClaimTypes.Role, user.Role.Name), }; var token = new JwtSecurityToken( issuer: Configuration["Issuer"], audience: Configuration["Audience"], expires: DateTime.UtcNow.AddHours(double.Parse(Configuration["ExpirationHours"])), notBefore: DateTime.UtcNow, claims: claims, signingCredentials: new SigningCredentials( new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["SigninKey"])), SecurityAlgorithms.HmacSha256Signature) ); var encoded = new JwtSecurityTokenHandler().WriteToken(token); return(Ok(new { token = encoded, user = new UserViewModel { Email = user.Email, Role = user.Role.Name, Id = user.Id } })); }
public AdminController(IUserSevice userSevice, IFreeSql freeSql) { _userSevice = userSevice; _freeSql = freeSql; }
public WaterController(IUserSevice userSevice, IMapper mapper, MysqlContext mysqlContext) : base(mapper) { _userService = userSevice; context = mysqlContext; }
public AccountApiController(IUserSevice userService, ISignInManager signInManager, IGroupService groupService) { UserService = userService; SignInManager = signInManager; GroupService = groupService; }
public UsersController(IUserSevice users, UserManager <User> userManager) { this.users = users; this.userManager = userManager; }
public LoginController(IUserSevice userSevice) { this.userSevice = userSevice; }
public AccountController(IUserSevice userService, ISignInManager signInManager, IMapper mapper) { UserService = userService; Mapper = mapper; SignInManager = signInManager; }
public UserController(IUserSevice userSevice) { _userServices = userSevice; }
public PermissionAuthorizationHandler(IUserSevice userService) { _userService = userService; }
public async Task <IActionResult> Register([FromBody] RegisterViewModel model, [FromServices] IUserSevice userSevice, [FromServices] IMapper mapper) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var id = await userSevice.CreateUserAsync(mapper.Map <RegisterViewModel, CreateUserModel>(model)); return(Ok(new { userId = id })); }