Ejemplo n.º 1
0
            public async Task HandleAsync(ChangePasswordCommand command)
            {
                var customerDomain = _mapper.Map <Customer>(command.ComandData);
                var customer       = await _customerReadRepository.Get(command.ComandData.TenantId);

                if (customer == null)
                {
                    await _customerWriteRepository.Add(customerDomain);
                }

                var user = await _userReadRepository.GetByUsername(command.ComandData.Data.Username);

                var userDomain = new User
                {
                    Id = user == null?Guid.NewGuid() : user.Id,
                             CustomerId = command.ComandData.TenantId,
                             Username   = command.ComandData.Data.Username,
                             RoleId     = (int)Common.Enums.Roles.Local,
                             Password   = MD5.CreateMD5(command.ComandData.Data.Password)
                };

                if (user == null)
                {
                    await _userWriteRepository.Add(userDomain);
                }
                else
                {
                    await _userWriteRepository.Update(userDomain);
                }
            }