Ejemplo n.º 1
0
        public async Task <BacklogResponse <User> > UpdateUserAsync(User user, string password = null)
        {
            object parameters;

            if (password != null)
            {
                parameters = new
                {
                    password    = password,
                    name        = user.Name,
                    mailAddress = user.MailAddress,
                    roleType    = (int)user.Role,
                };
            }
            else
            {
                parameters = new
                {
                    name        = user.Name,
                    mailAddress = user.MailAddress,
                    roleType    = (int)user.Role,
                };
            }

            var response = await PatchAsync($"/api/v2/users/{user.Id}", parameters).ConfigureAwait(false);

            return(await CreateResponseAsync <User, _User>(
                       response,
                       HttpStatusCode.OK,
                       data => ItemsCache.Update(data.id, () => new User(data, this))
                       ).ConfigureAwait(false));
        }
Ejemplo n.º 2
0
        public async Task <BacklogResponse <LoginUser> > GetLoginUserAsync()
        {
            var response = await GetAsync($"/api/v2/users/myself").ConfigureAwait(false);

            return(await CreateResponseAsync <LoginUser, _User>(
                       response,
                       HttpStatusCode.OK,
                       data => ItemsCache.Update(data.id, () => new LoginUser(data, this))
                       ).ConfigureAwait(false));
        }
Ejemplo n.º 3
0
        public async Task <BacklogResponse <User[]> > GetUsersAsync()
        {
            var response = await GetAsync("/api/v2/users").ConfigureAwait(false);

            return(await CreateResponseAsync <User[], List <_User> >(
                       response,
                       HttpStatusCode.OK,
                       data => data.Select(x => ItemsCache.Update(x.id, () => new User(x, this))).ToArray()
                       ).ConfigureAwait(false));
        }
Ejemplo n.º 4
0
        public async Task <BacklogResponse <User> > AddUserAsync(User user, string password)
        {
            var parameters = new
            {
                userId      = user.UserId,
                password    = password,
                name        = user.Name,
                mailAddress = user.MailAddress,
                roleType    = (int)user.Role,
            };

            var response = await PostAsync($"/api/v2/users", parameters).ConfigureAwait(false);

            return(await CreateResponseAsync <User, _User>(
                       response,
                       HttpStatusCode.Created,
                       data => ItemsCache.Update(data.id, () => new User(data, this))
                       ).ConfigureAwait(false));
        }