예제 #1
0
        private int IsExistClient(ClientDTO clientDTO)
        {
            var client = repositories.ClientRepos.Get().Where(c => c.UniqueName == clientDTO.UniqueName || c.Account.Email == clientDTO.Account.Email || c.Account.Phone == clientDTO.Account.Phone).FirstOrDefault();

            if (client == null)
            {
                return(-1);
            }
            else
            {
                return(client.Id);
            }
        }
예제 #2
0
        public ClientDTO CreateNewClient(ClientDTO clientDTO, string password)
        {
            var id = IsExistClient(clientDTO);

            if (id == -1)
            {
                clientDTO.Account.Password = password;
                repositories.ClientRepos.Insert(mapper.Map <Client>(clientDTO));
                repositories.Save();
                repositories.ClientRepos.Get().LastOrDefault().AccountId = repositories.AccountRepos.Get().LastOrDefault().ClientId;
                repositories.Save();
                return(mapper.Map <ClientDTO>(repositories.ClientRepos.Get().LastOrDefault()));
            }
            else
            {
                return(null);
            }
        }
예제 #3
0
        public bool SetProperties(ClientDTO clientDTO)
        {
            var id = IsNotExistClient(clientDTO);

            if (id == -1)
            {
                var client = repositories.ClientRepos.Get().Where(c => c.Id == clientDTO.Id).FirstOrDefault();
                client.Name          = clientDTO.Name;
                client.UniqueName    = clientDTO.UniqueName;
                client.Account.Email = clientDTO.Account.Email;
                client.Account.Phone = clientDTO.Account.Phone;
                repositories.ClientRepos.Update(client);
                repositories.Save();
                return(true);
            }
            else
            {
                return(false);
            }
        }