Пример #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);
                }
            }
Пример #2
0
            public async Task HandleAsync(ChangeMarginCommand command)
            {
                var customer = await _customerReadRepository.Get(command.ComandData.TenantId);

                if (customer == null)
                {
                    customer = new Domain.Customers.Customer
                    {
                        Id         = command.ComandData.TenantId,
                        CreateDate = DateTime.Now,
                        Margin     = command.ComandData.Data.Margin
                    };

                    await _customerWriteRepository.Add(customer);
                }
                else
                {
                    customer.Margin = command.ComandData.Data.Margin;
                    await _customerWriteRepository.Update(customer);
                }
            }
Пример #3
0
            public async Task <GetCustomerModel> HandleAsync(GetCustomerFromMsGraf query)
            {
                var customer = await _cspClient.GetCustomerAsync(query.TenantId.ToString());

                var customerDb = await _customerReadRepository.Get(query.TenantId);

                var user = await _userReadRepository.GetFirstByCustomerId(query.TenantId);

                return(new GetCustomerModel
                {
                    Domain = customer?.Domain,
                    Address = customer?.Address,
                    PhoneNumber = customer?.PhoneNumber,
                    City = customer?.City,
                    Country = customer?.Country,
                    PostalCode = customer?.PostalCode,
                    Name = customer?.Name,
                    Margin = customerDb?.Margin,
                    Email = user?.Username
                });
            }