示例#1
0
 public AssignUserWindow(ManageUsersPage page, Guid projectId)
 {
     InitializeComponent();
     this.page              = page;
     this.projectId         = projectId;
     commandQueryDispatcher = new CommandQueryDispatcher();
 }
        private async void Login()
        {
            bool isServerLocal = false;

            if (LocalWork.IsChecked.HasValue && LocalWork.IsChecked.Value)
            {
                isServerLocal = true;
            }

            HttpClientProvider.SetHttpClientUri(isServerLocal);

            var commandQueryDispatcher = new CommandQueryDispatcher();
            var login = new Login(LoginTextBox.Text, PasswordTextBox.Password);

            var response = await commandQueryDispatcher.SendAsync(login, "api/user-management/users/login", HttpOperationType.POST);

            if (response.StatusCode == HttpStatusCode.OK)
            {
                await SetUpCurrentUser(commandQueryDispatcher, LoginTextBox.Text);

                var projectsWindow = new MainWindow();
                projectsWindow.Top  = this.Top;
                projectsWindow.Left = this.Left;
                projectsWindow.Show();
                Close();
            }
            else
            {
                ResponseExtensions.ToMessageBox(response.ResponseContent);
            }
        }
示例#3
0
        public async Task <ActionResult <TwithDetailedViewDto> > Unlike([FromRoute] Guid id)
        {
            var userId = _identityUserManager.GetCurrentUserId(User);
            await CommandQueryDispatcher.SendCommandAsync(new UnlikeTwithCommand(id, userId));

            return(Ok(await CommandQueryDispatcher.SendQueryAsync(new GetTwithQuery(id, userId))));
        }
示例#4
0
        public async Task <ActionResult <TwithDetailedViewDto> > Update([FromRoute] Guid id,
                                                                        [FromBody] UpdateTwithRequest request)
        {
            await CommandQueryDispatcher.SendCommandAsync(new UpdateTwithCommand(id, request.Content));

            return(Ok(
                       await CommandQueryDispatcher.SendQueryAsync(new GetTwithQuery(id, _identityUserManager.GetCurrentUserId(User)))
                       ));
        }
示例#5
0
        public async Task <ActionResult <ListResponse <LikeDto> > > GetTwithLikes([FromRoute] Guid id,
                                                                                  [FromQuery] GetTwithLikesRequest request)
        {
            var likes = await CommandQueryDispatcher.SendQueryAsync(
                new GetTwithLikesQuery(request.Limit, request.Offset, id, _identityUserManager.GetCurrentUserId(User))
                );

            return(Ok(new ListResponse <LikeDto>(likes)));
        }
        private async Task SetUpCurrentUser(CommandQueryDispatcher commandQueryDispatcher, string email)
        {
            var response = await commandQueryDispatcher.SendAsync <UserResponse>($"api/user-management/users/{email}");

            var user = response.ResponseContent;

            CurrentUser.Id       = user.Id;
            CurrentUser.Email    = user.Email;
            CurrentUser.FullName = $"{user.FirstName} {user.LastName}";
            CurrentUser.Type     = (UserType)Enum.Parse(typeof(UserType), user.Role);
        }
        public MainWindow()
        {
            InitializeComponent();
            Title = "Project Management";

            CommandQueryDispatcher = new CommandQueryDispatcher();
            ProjectsPage           = new ProjectsPage(this);
            MainFrame.Content      = ProjectsPage;
            AddProjectPage         = new AddProjectPage(this);
            UsersPage      = new UsersPage(this);
            CreateUserPage = new CreateUserPage(this);
        }
示例#8
0
        public async Task <ActionResult <ListResponse <TwithListViewDto> > > GetList([FromQuery] GetTwithListRequest request)
        {
            var query = new GetTwithsListQuery(
                request.Limit,
                request.Offset,
                _identityUserManager.GetCurrentUserId(User)
                );

            return(Ok(
                       new ListResponse <TwithListViewDto>(await CommandQueryDispatcher.SendQueryAsync(query))
                       ));
        }
示例#9
0
        public async Task <ActionResult <TwithDetailedViewDto> > Create([FromBody] CreateTwithRequest request)
        {
            var userId  = _identityUserManager.GetCurrentUserId(User);
            var command = new CreateTwithCommand(
                Guid.NewGuid(),
                request.Content,
                userId
                );

            await CommandQueryDispatcher.SendCommandAsync(command);

            return(Ok(await CommandQueryDispatcher.SendQueryAsync(new GetTwithQuery(command.Id, userId))));
        }
示例#10
0
        public async Task <ActionResult <UserDetailedViewDto> > UpdatePersonalData(
            [FromBody] UpdatePersonalDataRequest request)
        {
            var userId  = _identityUserManager.GetCurrentUserId(User);
            var command = new UpdatePersonalDataCommand(
                userId,
                request.FirstName,
                request.LastName
                );

            await CommandQueryDispatcher.SendCommandAsync(command);

            return(Ok(await CommandQueryDispatcher.SendQueryAsync(new GetUserQuery(userId))));
        }
示例#11
0
        public async Task <ActionResult <AuthResponse> > SignIn([FromBody] SignInRequest request)
        {
            var(identityUser, token) = await _identityUserManager.SignInAsync(request.Email, request.Password);

            var user = await CommandQueryDispatcher.SendQueryAsync(new GetUserQuery(Guid.Parse(identityUser.Id)));

            return(Ok(new AuthResponse(
                          user.Id,
                          user.Email,
                          user.FirstName,
                          user.LastName,
                          user.NickName,
                          token
                          )));
        }
示例#12
0
        public async Task <ActionResult <AuthResponse> > SignUp([FromBody] SignUpRequest request)
        {
            var identityUser = await _identityUserManager.CreateAsync(request.Email, request.Password);

            var command = new CreateUserCommand(
                Guid.Parse(identityUser.Id),
                request.Email,
                request.FirstName,
                request.LastName,
                request.NickName
                );
            await CommandQueryDispatcher.SendCommandAsync(command);

            return(Ok(new AuthResponse(
                          command.Id,
                          command.Email,
                          command.FirstName,
                          command.LastName,
                          command.NickName,
                          _identityUserManager.GetTokenForUser(identityUser)
                          )));
        }
示例#13
0
 public IssueStatusModifier(CommandQueryDispatcher commandQueryDispatcher)
 {
     this.commandQueryDispatcher = commandQueryDispatcher;
 }
示例#14
0
        public async Task <ActionResult> Delete([FromRoute] Guid id)
        {
            await CommandQueryDispatcher.SendCommandAsync(new DeleteTwithCommand(id));

            return(NoContent());
        }