public async Task <HttpResponseMessage> Put(ClientModel model)
        {
            // Change e-mail
            await _userService.ChangeEmailAsync(UserId, model.Email);

            // Update user
            var userUpdate = new UserUpdateOptions
            {
                Country  = model.Country,
                UserName = model.ContactPerson
            };

            DomainUser user = await _userService.UpdateAsync(UserId, userUpdate);

            // Update company
            var companyUpdate = new CompanyUpdateOptions
            {
                Address = model.Address,
                Country = model.Country,
                Ein     = model.Ein,
                Name    = model.CompanyName,
                Phone   = model.PhoneNumber,
                ZipCode = model.ZipCode,
                Email   = model.Email
            };

            DomainCompany company = await _companyService.UpdateByUserAsync(UserId, companyUpdate);

            Client client = _mapper.Map <Tuple <DomainUser, DomainCompany>, Client>(new Tuple <DomainUser, DomainCompany>(user, company));

            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, client);

            return(response);
        }
        public async Task <DomainUser> UpdateAsync(string userId, UserUpdateOptions update)
        {
            var user = await _userRepository.GetAsync(userId);

            if (user == null)
            {
                throw new NotFoundException(string.Format("Could not find user '{0}'.", userId));
            }

            // Patching
            user.Modified = DateTime.UtcNow;
            user.Name     = update.UserName;
            user.NameSort = update.UserName == null ? null : update.UserName.ToLowerInvariant();
            user.City     = update.City;
            user.Country  = update.Country;
            user.Timezone = update.Timezone;
            user.NotifyOnVideoComments = update.NotifyOnVideoComments;

            user = await _userRepository.UpdateAsync(user);

            // Calculate storage space
            var storageSpace = _fileRepository.Context.Where(p => p.UserId == userId).ToList();

            var profile = _mapper.Map <UserEntity, DomainUser>(user);

            profile.UsedStorageSpace = storageSpace.Where(p => !p.IsArtifact).Sum(p => p.Length);

            return(profile);
        }
        protected internal virtual Request replaceUserRequest(string
                                                              database, string user, UserUpdateOptions options)
        {
            Request request;

            request = new Request(database, RequestType
                                  .PUT, this.executor.createPath(ArangoDBConstants.PATH_API_USER
                                                                 , user));
            request.setBody(this.executor.Serialize(options != null ? options : new UserUpdateOptions
                                                        ()));
            return(request);
        }
        public async Task <UpdateResult <User> > UpdateUserAsync(UserUpdateOptions updateOptions)
        {
            var updateResult = new UpdateResult <User>();

            try
            {
            }
            catch (Exception ex)
            {
            }

            return(updateResult);
        }
Exemple #5
0
 /// <summary>Replaces the data of an existing user.</summary>
 /// <remarks>
 /// Replaces the data of an existing user. The name of an existing user must be specified in user. You can only
 /// change the password of your self. You need access to the _system database to change the active flag.
 /// </remarks>
 /// <seealso><a href="https://docs.arangodb.com/current/HTTP/UserManagement/index.html#replace-user">API
 /// *      Documentation</a></seealso>
 /// <param name="user">The name of the user</param>
 /// <param name="options">Additional properties of the user, can be null</param>
 /// <returns>information about the user</returns>
 /// <exception cref="ArangoDBException"/>
 /// <exception cref="ArangoDBException"/>
 public virtual UserEntity replaceUser(string user, UserUpdateOptions
                                       options)
 {
     return(executor.execute(this.replaceUserRequest(this.db().name(), user, options),
                             typeof(UserEntity)));
 }