コード例 #1
0
        public async Task Handle(SaveClientCommand request, CancellationToken cancellationToken)
        {
            if (!request.IsValid())
            {
                NotifyValidationErrors(request);
                return;
            }

            var savedClient = await _clientRepository.GetByClientId(request.Client.ClientId);

            if (savedClient != null)
            {
                await Bus.RaiseEvent(new DomainNotification("1", "Client already exists"));

                return;
            }

            PrepareClientTypeForNewClient(request);
            var client = request.Client.ToEntity();

            client.Description = request.Description;

            _clientRepository.Add(client);

            if (Commit())
            {
                await Bus.RaiseEvent(new NewClientEvent(request.Client.ClientId, request.ClientType, request.Client.ClientName));
            }
        }
コード例 #2
0
        public Tiers Add(Tiers Tiers)
        {
            Tiers      result     = new Tiers();
            Parametres parametres = _parametresService.GetAll();



            if (!parametres.INCCLI)
            {
                if (!(CheckUnicCodification(Tiers.Numero)))
                {
                    Tiers.Type = 0;
                    _clientRepository.Add(Tiers);
                    result = Tiers;
                }
                else
                {
                    result = null;
                }
            }
            else
            {
                Tiers.Numero = parametres.NUMCLI;
                while (CheckUnicCodification(Tiers.Numero))
                {
                    Tiers.Numero = Tiers.Numero.IncrementCode();
                }
                Tiers.Type        = 0;
                result            = _clientRepository.Add(Tiers);
                parametres.NUMCLI = Tiers.Numero;
                _parametresService.Update(parametres);
            }
            return(result);
        }
コード例 #3
0
        public async Task <bool> Handle(SaveClientCommand request, CancellationToken cancellationToken)
        {
            if (!request.IsValid())
            {
                NotifyValidationErrors(request);
                return(false);
            }

            var savedClient = await _clientRepository.GetByClientId(request.Client.ClientId);

            if (savedClient != null)
            {
                await Bus.RaiseEvent(new DomainNotification("Client", "Client already exists"));

                return(false);
            }

            var client = request.ToEntity();

            _clientRepository.Add(client);

            if (await Commit())
            {
                await Bus.RaiseEvent(new NewClientEvent(request.Client.ClientId, request.ClientType, request.Client.ClientName));

                return(true);
            }

            return(false);
        }
コード例 #4
0
        public Client Add(Client client)
        {
            Client result = new Client();

            var codification = _parametresService.Check_IncrementCodification();

            if (codification == 0)
            {
                if (!CheckUnicCodification(client.Numero))
                {
                    _ClientRepository.Add(client);
                    result = client;
                }
                else
                {
                    result = null;
                }
            }
            else if (codification == 1)
            {
                Parametres parametre  = _parametresService.GetAll();
                string     codeClient = parametre.NUMCLI;

                client.Numero    = codeClient.IncrementCode();
                result           = _ClientRepository.Add(client);
                parametre.NUMCLI = client.Numero;
                _parametresService.UpdateNUMCLI(codeClient);
            }

            return(result);
        }
コード例 #5
0
        public Client Add(Client client)
        {
            Client     result     = new Client();
            Parametres parametres = _parametresService.GetAll();



            if (!parametres.INCCLI)
            {
                if (!(CheckUnicCodification(client.Numero)))
                {
                    _ClientRepository.Add(client);
                    result = client;
                }
                else
                {
                    result = null;
                }
            }
            else
            {
                client.Numero = parametres.NUMCLI;
                while (CheckUnicCodification(client.Numero))
                {
                    client.Numero = client.Numero.IncrementCode();
                }

                result            = _ClientRepository.Add(client);
                parametres.NUMCLI = client.Numero;
                _parametresService.Update(parametres);
            }
            return(result);
        }
コード例 #6
0
 public MockNetworkLayer(ulong threadCount, IClientRepository clientRepository) : base(threadCount, clientRepository)
 {
     a           = new Client(threadCount, "a");
     a.Dimension = 0;
     a.Position  = new Vector3(0, 0, 0);
     b           = new Client(threadCount, "b");
     b.Dimension = 0;
     b.Position  = new Vector3(100, 100, 100);
     clientRepository.Add(a);
     clientRepository.Add(b);
 }
コード例 #7
0
        public MockNetworkLayer(IClientRepository clientRepository) : base(clientRepository)
        {
            var a = new Client("a");

            a.Dimension = 0;
            a.Position  = new Vector3(0, 0, 0);
            var b = new Client("b");

            b.Dimension = 0;
            b.Position  = new Vector3(100, 100, 100);
            clientRepository.Add(a);
            clientRepository.Add(b);
        }
コード例 #8
0
        public async Task <ActionResult> PersonalInfoForm(Client client)
        {
            Client clientEntity = client;

            // Validates whether the email is unique
            if (ModelState.IsValidField("Email") && _clientRepo.EmailTaken(clientEntity.Email))
            {
                ModelState.AddModelError("Email", Resources.Checkout.EmailNotUnique);
            }

            // If there are no validation errors
            if (ModelState.IsValid)
            {
                // Save the client and create a cookie
                _clientRepo.Add(clientEntity);
                await _clientRepo.SaveChangesAsync();

                AddClientCookie(client.ID);

                // Redirect to the next step
                return(RedirectToAction("DeliveryOption", "Orders"));
            }
            else
            {
                // Enables to show the validation summary
                ViewBag.ShowValidationSummary = true;
                // Show the form again
                return(View("PersonalInfoForm", client));
            }
        }
コード例 #9
0
        public Object Join([FromBody, Required, RegularExpression(@"\S{1,64}")] string name)
        {
            string id = _clientRepository.Add(name);

            if (null != id)
            {
                _msgService.Init(id);

                // Send information message about new user.
                Message msg_info = new Message {
                    type = MessageType.TextMessage, from_id = "", to_id = "", data = new { text = $"{name} ({id}) has joined to the chat." }
                };
                _msgService.AddMessage(msg_info);

                // Send updated list of users.
                Message msg = new Message {
                    type = MessageType.UsersList, from_id = "", to_id = "", data = _clientRepository.Clients.ToArray()
                };
                _msgService.AddMessage(msg);

                return(id as Object);
            }

            return(string.Empty as Object);
        }
コード例 #10
0
        public async Task Create(ClientDto clientDto)
        {
            ValidateClientDto(clientDto);

            await AddApiResourceIfMissing(clientDto.AllowedScopes);

            var grantType = GetGrantType(clientDto);

            var client = new Client
            {
                ClientId          = clientDto.Username,
                AllowedGrantTypes = new List <ClientGrantType>
                {
                    new ClientGrantType {
                        GrantType = grantType
                    }
                },
                ClientSecrets = new List <ClientSecret>
                {
                    new ClientSecret {
                        Value = clientDto.Password.Sha256()
                    }
                },
                AllowedScopes = clientDto.AllowedScopes.Select(x => new ClientScope {
                    Scope = x.Name
                }).ToList()
            };

            await _clientRepository.Add(client);
        }
コード例 #11
0
        public async Task Execute(Client client)
        {
            if (client.Cpf == null)
            {
                throw new UserNotDefinid(
                          "CPF de cliente não foi definido."
                          );
            }

            Client userExist;

            client.UserRole = UserRole.Client;
            userExist       = await _repository.FindByPersonRegisterNot(client);

            if (userExist != null)
            {
                throw new UniqUserRegisterCpf("Usuário já registrado.");
            }

            var hashPassword = new HashPasswordService();

            client.Password = hashPassword.EncryptPassword(client.Password);

            if (client.Id == 0)
            {
                await _repository.Add(client);

                return;
            }
            await _repository.Update(client);
        }
コード例 #12
0
 public IActionResult Save(Client_VM client_VM)
 {
     if (client_VM != null)
     {
         if (client_VM.Id > 0)
         {
             if (_clientRepository.Update(client_VM, this.loginUserId) > 0)
             {
                 TempData["Status"]  = Helper.success_code;
                 TempData["Message"] = Message.clientUpdated;
             }
             else
             {
                 TempData["Message"] = Message.clientUpdateError;
             }
         }
         else
         {
             if (_clientRepository.Add(client_VM, this.loginUserId) > 0)
             {
                 TempData["Status"]  = Helper.success_code;
                 TempData["Message"] = Message.clientAdded;
             }
             else
             {
                 TempData["Message"] = Message.clientAddedError;
             }
         }
     }
     return(RedirectToAction("List", "Client"));
 }
コード例 #13
0
        public async Task <IActionResult> AddAsync([FromBody] ClientRequest request)
        {
            Response response = new Response();

            if (!ModelState.IsValid || request == null)
            {
                return(BadRequest());
            }
            try
            {
                Client client = new Client()
                {
                    Name = request.Name
                };
                _clienteRepository.Add(client);
                await _clienteRepository.SaveAsync();

                response.Success = true;
                response.Data    = client;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
            }
            return(Ok(response));
        }
コード例 #14
0
        public ClientViewModel Add(ClientViewModel client)
        {
            var idSpec    = new ClientByIdSpec(client.Id);
            var oldClient = clientRepository.FindById(client.Id);

            if (oldClient != null)
            {
                throw new ArgumentException($"Client with id ({client.Id}) already exist.");
            }

            var newClient = Client.Create(client.Name, client.IsResident, client.Address, client.Phone);

            try
            {
                unitOfWork.BeginTransaction();
                clientRepository.Add(newClient);
                unitOfWork.Commit();
            }
            catch (Exception)
            {
                unitOfWork.Rollback();
                throw;
            }

            client.Id = newClient.Id;
            return(client);
        }
コード例 #15
0
        public async Task <IActionResult> Post([FromBody] ClientCreationViewModel clientVm)
        {
            if (clientVm == null)
            {
                return(BadRequest());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var newItem = Mapper.Map <Client>(clientVm);

            //newItem.SetCreation(UserName);
            _clientRepository.Add(newItem);
            if (!await UnitOfWork.SaveAsync())
            {
                return(StatusCode(500, "保存客户时出错"));
            }

            var vm = Mapper.Map <ClientViewModel>(newItem);

            return(CreatedAtRoute("GetClient", new { id = vm.Id }, vm));
        }
コード例 #16
0
ファイル: ClientService.cs プロジェクト: umair-me/ASA-API
        public Client Add(Client client)
        {
            var newClient = _client.Add(client);

            SaveCommit();
            return(newClient);
        }
コード例 #17
0
        public void SendMessageAndSaveClient()
        {
            var client = new Client();

            _repository.Add(client);
            _message.Send();
        }
コード例 #18
0
ファイル: AddForm.cs プロジェクト: abderrahim1920/GPS
 private void iconButton1_Click(object sender, EventArgs e)
 {
     if (ValidateChildren(ValidationConstraints.Enabled))
     {
         ClientDTO client = new ClientDTO
         {
             City        = cityTextBox.Text,
             Login       = loginTextBox.Text,
             Name        = NameTextBox.Text,
             PhoneNumber = phoneNumberTextBox.Text,
         };
         var mappedEntity = _mapper.Map <Client>(client);
         _clientRepository.Add(mappedEntity);
         TraceDTO trace = new TraceDTO
         {
             CreationDate = creationDateTime.Value,
             IMEI         = iMEITextBox.Text,
             Name         = traceNameTextBox.Text,
             Number       = phoneNumberTextBox.Text,
             RenewDate    = DateTime.Now.AddDays(365),
             ClientId     = mappedEntity.ClientId
         };
         var traceMapped = _mapper.Map <Trace>(trace);
         _tracerepository.Add(traceMapped);
     }
 }
コード例 #19
0
        private Client CreateNewClient()
        {
            var client = new Client();

            _clientRepository.Add(client);
            return(client);
        }
コード例 #20
0
        public int AddClient(ClientRegistrationInfo clientInfo)
        {
            if (validator.ValidateClientInfo(clientInfo))
            {
                var clientToAdd = new ClientEntity()
                {
                    ClientFirstName = clientInfo.FirstName,
                    ClientLastName  = clientInfo.LastName,
                    PhoneNumber     = clientInfo.PhoneNumber
                };

                clientsRepository.Add(clientToAdd);
                clientsRepository.SaveChanges();

                var balance = new BalanceEntity()
                {
                    ClientID      = clientToAdd.ClientID,
                    ClientBalance = 0
                };

                balanceRepository.Add(balance);
                balanceRepository.SaveChanges();
                return(clientToAdd.ClientID);
            }
            return(-1);
        }
コード例 #21
0
        public ActionResult <ClientDTO> PostClientDTO(ClientDTO clientDTO)
        {
            _clientRepository.Add(clientDTO);
            _clientRepository.Save();

            return(CreatedAtAction("GetClientDTO", new { id = clientDTO.Id }, clientDTO));
        }
コード例 #22
0
        public Client Add(Client client)
        {
            Client result = new Client();

            result = _ClientRepository.Add(client);
            return(result);
            //var codification = _parametresService.Check_IncrementCodification();
            //if (codification == 0)
            //{
            //    if (!CheckUnicCodification(client.Codification))
            //    {
            //        _ClientRepository.Add(client);
            //        result = client;

            //    }
            //    else
            //    {
            //        result = null;
            //    }

            //}
            //else if (codification == 1)
            //{
            //    Parametres parametre = _parametresService.GetAll();
            //    string codeClient = parametre.NUMCLI;

            //    client.Codification = codeClient.IncrementCode();
            //    result = _ClientRepository.Add(client);
            //    parametre.NUMCLI = client.Codification;
            //    _parametresService.UpdateNUMCLI(codeClient);
            //}

            //return result;
        }
コード例 #23
0
        public async Task Invoke(
            HttpContext context,
            IDeviceResolver deviceResolver,
            IBrowserResolver browserResolver,
            IClientRepository clientRepository)
        {
            if (!deviceResolver.Device.Crawler)
            {
                Parser     uaParser   = Parser.GetDefault();
                ClientInfo clientInfo = null;

                Guid clientId  = Guid.Empty;
                Guid sessionId = Guid.Empty;

                var cookieId       = context.Request.Cookies[_key];
                var isExistingUser = context.Request.Cookies.ContainsKey(_key);
                if (!isExistingUser || !Guid.TryParse(cookieId, out clientId) || clientRepository.Get(clientId) is null)
                {
                    clientId = Guid.NewGuid();
                    var userAgent = deviceResolver.UserAgent.ToString();
                    if (clientInfo is null)
                    {
                        clientInfo = uaParser.Parse(userAgent);
                    }
                    context.Response.Cookies.Append(_key, clientId.ToString());
                    var newClient = new DAL.Entities.Client()
                    {
                        ClientId        = clientId,
                        Ip              = context.Connection.RemoteIpAddress.ToString(),
                        Device          = deviceResolver.Device.Type.ToString(),
                        Browser         = browserResolver.Browser.Type.ToString(),
                        BrowserVersion  = browserResolver.Browser.Version.ToString(),
                        Platform        = clientInfo.OS.Family,
                        PlatformVersion = clientInfo.OS.Major,
                    };
                    clientRepository.Add(newClient);
                }
                if (clientInfo is null)
                {
                    clientInfo = uaParser.Parse(deviceResolver.UserAgent.ToString());
                }
                var onlineClient = new OnlineClientViewModel()
                {
                    ClientId     = clientId,
                    Ip           = context.Connection.RemoteIpAddress.ToString(),
                    UserAgent    = $"Device: {deviceResolver.Device.Type.ToString()}, OS: {clientInfo.OS.Family} - {clientInfo.OS.Major}, Browser: {browserResolver.Browser.Type.ToString()} - {browserResolver.Browser.Version.ToString()}",
                    LastActivity = DateTime.Now
                };
                OnlineClients.AddOrUpdate(clientId.ToString(), onlineClient, (key, value) => { value.LastActivity = DateTime.Now; return(value); });
            }
            foreach (var item in OnlineClients)
            {
                if ((DateTime.Now - item.Value.LastActivity).Seconds >= _timeout)
                {
                    OnlineClients.Remove(item.Key, out OnlineClientViewModel deletedUser);
                }
            }
            await _next(context);
        }
コード例 #24
0
        public async Task <Client> Handle(CreateClientCommand message, CancellationToken cancellationToken)
        {
            var client = await Client.Factory.CreateNewEntry(_repository, message.ClientName, message.ClientTypeId);

            await _repository.Add(client);

            return(client);
        }
コード例 #25
0
        public long Add(ClientRegisterCommand clientCmd)
        {
            var client = Mapper.Map <ClientRegisterCommand, Client>(clientCmd);

            var newClient = _clientRepository.Add(client);

            return(newClient.Id);
        }
コード例 #26
0
        public Client Add(string Name, string Surname, string Address, string PostalCode, string CNP,
                          string Country, string City, string District, string PhoneNumber, string Mail)
        {
            var client = Client.Create(Name, Surname, Address, PostalCode, CNP, Country, City,
                                       District, PhoneNumber, Mail);

            return(clientRepository.Add(client));
        }
コード例 #27
0
        public int Add(Client client)
        {
            client.Validate();

            var newClient = _clientRepository.Add(client);

            return(newClient.Id);
        }
コード例 #28
0
ファイル: ClientService.cs プロジェクト: nkerkez/Time-Sheet
        public void Add(Models.Client client)
        {
            ValidateModel(client);

            client.Id = Guid.NewGuid();

            _clientRepository.Add(client);
        }
コード例 #29
0
        public override async Task <Empty> CreateClient(ClientModel client, ServerCallContext context)
        {
            await _repository.Add(client);

            SendMessage(client, "create");

            return(new Empty());
        }
コード例 #30
0
        public async Task <BatchDTO> PerformLoadAsync(ClientDTO clientDTO, ContactDTO contactDTO, CardDTO carDTO, BatchDTO batchDTO)
        {
            var client = (await _clientRepository.FilterAsync(filter: c => c.Ruc == clientDTO.Ruc,
                                                              includeProperties: "Contacts.Cards")).FirstOrDefault();

            if (client == null)
            {
                client = new Client(clientDTO.Ruc, clientDTO.Address, clientDTO.Email, clientDTO.Name, clientDTO.Phone);
            }
            else
            {
                client.UpdateFields(clientDTO.Ruc, clientDTO.Address, clientDTO.Email, clientDTO.Name, clientDTO.Phone);
            }
            var mainContact = await _contactRepository.CreateOrUpdateMainContact(client, contactDTO.Phone, contactDTO.DocumentType,
                                                                                 contactDTO.DocumentNumber, contactDTO.FirstName,
                                                                                 contactDTO.LastName, contactDTO.Email);

            var card        = mainContact.Cards.FirstOrDefault(c => c.CardTypeId == carDTO.CardTypeId);
            var cardType    = _cardTypeRepository.Get(carDTO.CardTypeId);
            var batchReason = "Recarga de saldo";

            if (card == null)
            {
                batchReason = "Creación de tarjeta";
                card        = new Card(mainContact, cardType.Currency, carDTO.CardTypeId, carDTO.TPCode);
            }
            batchDTO.TPContractReason += " " + batchReason;
            var expire = DateTime.Now.AddDays(cardType.Term);
            var batch  = new Batch(
                new Money(batchDTO.Amount.Currency, batchDTO.Amount.Value),
                expire, batchDTO.TPChasis,
                batchDTO.TPContractDate,
                batchDTO.TPInvoiceCode,
                batchDTO.TPInvoiceDate,
                batchDTO.TPContractType,
                batchDTO.TPContractNumber,
                batchDTO.TPContractReason,
                batchDTO.DealerCode,
                batchDTO.DealerName,
                batchDTO.BusinessCode,
                batchDTO.BusinessDescription
                );

            client.Batches.Add(batch);
            _rechargeService.PerformRecharge(card, batch);

            if (client.Id == 0)
            {
                _clientRepository.Add(client);
            }
            else
            {
                _clientRepository.Modify(client);
            }
            await _clientRepository.UnitOfWork.CommitAsync();

            return(batch.ProjectedAs <BatchDTO>());
        }