コード例 #1
0
ファイル: Customer.cs プロジェクト: MarkHollander/Gico_System
        public void Register(CustomerRegisterCommand command)
        {
            Id   = Common.Common.GenerateGuid();
            Code = Common.Common.GenerateCodeFromId(command.SystemNumericalOrder, 3);
            string passwordHash = EncryptionExtensions.Encryption(Code, command.Password, out string salt);

            CreatedDateUtc       = command.CreatedDateUtc;
            CreatedUid           = string.Empty;
            UpdatedDateUtc       = command.CreatedDateUtc;
            UpdatedUid           = string.Empty;
            Email                = command.Email;
            PhoneNumber          = command.Mobile;
            EmailConfirmed       = false;
            IsTaxExempt          = false;
            FailedLoginAttempts  = 0;
            LastIpAddress        = command.RegisterIp;
            Password             = passwordHash;
            PasswordSalt         = salt;
            PhoneNumberConfirmed = false;
            TwoFactorEnabled     = EnumDefine.TwoFactorEnum.Disable;
            FullName             = command.FullName;
            Gender               = command.Gender;
            Birthday             = command.Birthday;
            AddType(CustomerTypeEnum.IsCustomer);
            Status = CustomerStatusEnum.New;
            RegisterEvent();
        }
コード例 #2
0
 public static CustomerRegisterCommandBuilder Start()
 {
     _command = new CustomerRegisterCommand()
     {
         Name     = "Dienisson",
         LastName = "Almeida",
         Sex      = Domain.Features.Flights.SexEnum.Male
     };
     return(new CustomerRegisterCommandBuilder());
 }
コード例 #3
0
        public void Update(CustomerRegisterCommand command)
        {
            var customer = _customerRepository.Get(command.Id);
            var city     = _addressRepository.GetCity(command.Address.CityCode);

            customer.Contact.Update(command.Contact.Phone, command.Contact.CellPhone, command.Contact.Email);
            customer.Address.Update(command.Address.Street, command.Address.Number, command.Address.ZipCode, city);
            customer.Update(command.Name, command.Lastname, command.CPF);

            _customerRepository.Update(customer);
        }
コード例 #4
0
 public ActionResult Edit(CustomerRegisterCommand command)
 {
     try
     {
         _customerAppService.Update(command);
         return(RedirectToAction("Index", _customerAppService.GetAll()));
     }
     catch
     {
         return(View());
     }
 }
コード例 #5
0
        public void Save(CustomerRegisterCommand command)
        {
            var customer = new Customer(command.Name
                                        , command.Lastname
                                        , command.CPF
                                        , new Contact(command.Contact.Phone, command.Contact.CellPhone, command.Contact.Email)
                                        , new Address(command.Address.Street
                                                      , command.Address.Number
                                                      , command.Address.ZipCode
                                                      , _addressRepository.GetCity(command.Address.CityCode)));

            _customerRepository.Save(customer);
        }
コード例 #6
0
        private async Task <ResponseMessage> RegisterCustomer(UserRegisteredIntegrationEvent message)
        {
            var customerCommand = new CustomerRegisterCommand(message.Id, message.Name, message.Email, message.Cpf);
            ValidationResult success;

            using (var scope = _serviceProvider.CreateScope())
            {
                var mediator = scope.ServiceProvider.GetRequiredService <IMediatorHandler>();
                success = await mediator.SendCommand(customerCommand);
            }

            return(new ResponseMessage(success));
        }
コード例 #7
0
        public ActionResult Create(CustomerRegisterCommand command)
        {
            try
            {
                _customerAppService.Save(command);


                return(View("Index", _customerAppService.GetAll()));
            }
            catch
            {
                return(View());
            }
        }
コード例 #8
0
        public async Task <CommandResult> SendCommand(CustomerRegisterCommand command)
        {
            CommandResult commandResult = await _commandService.SendAndReceiveResult <CommandResult>(command);

            return(commandResult);
        }