Ejemplo n.º 1
0
        public UIElement GetRegisterElement()
        {
            ClientRegisterViewModel viewModel = new ClientRegisterViewModel(new ClientRegisterModel()
            {
                DateOfBirth = new DateTime(1990, 01, 01)
            });
            RegisterClientControl control = new RegisterClientControl(viewModel);

            viewModel.ClientCreated += (s, e) =>
            {
                ClientRegisterModel client    = e.Client;
                ClientRegisterDTO   clientDTO = Mapper.Map <ClientRegisterModel, ClientRegisterDTO>(client);

                using (IAccountService service = factory.CreateAccountService())
                {
                    ServiceMessage serviceMessage = service.Register(clientDTO);
                    RaiseReceivedMessageEvent(serviceMessage);

                    if (serviceMessage.IsSuccessful)
                    {
                        viewModel.FirstName       = String.Empty;
                        viewModel.LastName        = String.Empty;
                        viewModel.PhoneNumber     = String.Empty;
                        viewModel.Login           = String.Empty;
                        viewModel.Password        = String.Empty;
                        viewModel.ConfirmPassword = String.Empty;
                        Notify();
                    }
                }
            };

            return(control);
        }
        private void RaiseClientCreatedEvent(ClientRegisterModel client)
        {
            var handler = ClientCreated;

            if (handler != null)
            {
                ClientEventArgs e = new ClientEventArgs(client);
                handler(this, e);
            }
        }
Ejemplo n.º 3
0
        private async Task <string> RegisterToDatabase(ClientRegisterModel toRegister)
        {
            Client dbClient = new()
            {
                UserId = toRegister.UserId
            };

            await _clients.InsertOneAsync(dbClient);

            return(dbClient.Id);
        }
Ejemplo n.º 4
0
        public async Task <ActionResult <string> > RegisterClient([FromBody] ClientRegisterModel clientRegisterModel)
        {
            string id;

            try
            {
                id = await _clientsService.RegisterClientAsync(clientRegisterModel);

                return(Ok(id));
            } catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Ejemplo n.º 5
0
        public async Task <string> RegisterClientAsync(ClientRegisterModel toRegister)
        {
            if (!UserExist(toRegister.UserId))
            {
                throw new Exception("The user doesn't exist");
            }
            if (ClientExist(toRegister.UserId))
            {
                throw new Exception("The client already exist");
            }

            string id = await RegisterToDatabase(toRegister);

            return(id);
        }
 public ClientRegisterViewModel(ClientRegisterModel client)
     : base(client)
 {
     this.client         = client;
     CreateClientCommand = new DelegateCommand(() => RaiseClientCreatedEvent(client), CanCreateBookmaker);
 }
 public ClientEventArgs(ClientRegisterModel client)
 {
     this.Client = client;
 }