//registration
        public async Task SendClientRegistrationNotification(string username)
        {
            ClientsFilter filter = new ClientsFilter {
                UserName = username
            };
            Client client = _clientService.GetAllClients(filter).Result.FirstOrDefault();
            User   user   = client?.User;

            if (user != null)
            {
                string emailTo = user.Email;
                if (emailTo != null)
                {
                    EmailModel email = new EmailModel
                    {
                        EmailsTo = new List <string> {
                            emailTo
                        },
                        Subject = EmailHelper.RegistrationSubject,
                        Message = EmailHelper.RegistrationMessage(user.FirstName, user.LastName)
                    };
                    await SendEmailAsync(email);
                }
            }
        }
Ejemplo n.º 2
0
        public async Task <IEnumerable <Client> > GetClientsAsync(ClientsFilter clientsFilter)
        {
            var result = await _repository.GetListAsync(new Dictionary <string, object>
            {
                { ClientsMetadata.FirstName, clientsFilter.FirstName },
                { ClientsMetadata.MiddleName, clientsFilter.MiddleName },
                { ClientsMetadata.LastName, clientsFilter.LastName },
                { AddressMetadata.RawAddress, clientsFilter.Address },
            }, clientsFilter.Offset, clientsFilter.Limit);

            return(result.Any() ? _mapper.Map <IEnumerable <Client> >(result) : null);
        }
        public void FindCustomersByNameTest()
        {
            var filter          = new ClientsFilter(context);
            var customersByName = filter.FindCustomersByName("Google Polska").ToList();

            Assert.AreEqual(1, customersByName.Count, "Customers count not valid");

            if (!customersByName.IsNullOrEmpty())
            {
                var first = customersByName.First();

                Assert.IsNotNull(first, "Empty customers list");
                Assert.AreEqual("Koszykowa 55555", first.Address, "Customer entity not valid");
            }
        }
        public void FindCustomersByNameTest()
        {
            var filter          = new ClientsFilter(context);
            var customersByName = filter.FindCustomersByName("Katarzyna Malinowska").ToList();

            Assert.AreEqual(1, customersByName.Count, "Customers count not valid");

            if (!customersByName.IsNullOrEmpty())
            {
                var first = customersByName.First();

                Assert.IsNotNull(first, "Empty customers list");
                Assert.AreEqual("Brzozowa 121", first.Address, "Customer entity not valid");
            }

            var customersByName2 = filter.FindCustomersByName("Marcin Brzozowski").ToList();

            Assert.AreEqual(0, customersByName2.Count, "Customers count not valid");
        }
        public void FindCustomersByOrderTime()
        {
            var filter = new ClientsFilter(context);

            var dateFrom = DateTime.Parse("2/11/2017 13:00");
            var dateTo1  = DateTime.Parse("2/11/2017 15:00");
            var dateTo2  = DateTime.Parse("2/11/2017 20:00");

            var customers1 = filter.FindCustomersByOrderTime(dateFrom, dateTo1).ToList();

            Assert.AreEqual(1, customers1.Count, "Customers count not valid");
            Assert.IsTrue(customers1.Any(c => c.Name == "Piotr Nowak"), "Customers not valid");

            var customers2 = filter.FindCustomersByOrderTime(dateFrom, dateTo2).ToList();

            Assert.AreEqual(2, customers2.Count, "Customers count not valid");
            Assert.IsTrue(customers2.Any(c => c.Name == "Jan Kowalski"), "Customers not valid");
            Assert.IsTrue(customers2.Any(c => c.Name == "Piotr Nowak"), "Customers not valid");
        }
Ejemplo n.º 6
0
        public async Task <ICollection <Client> > GetAllClients(
            ClientsFilter filter        = null,
            PaginationFilter pagination = null)
        {
            if (pagination != null && filter != null)
            {
                return(await _repositoryWrapper.ClientRepository.GetAsync(filter : Filter(filter), include : Include(),
                                                                          pageNumber : pagination.PageNumber, pageSize : pagination.PageSize));
            }

            if (filter != null)
            {
                return(await _repositoryWrapper.ClientRepository.GetAsync(filter : Filter(filter), include : Include()));
            }

            if (pagination != null)
            {
                return(await _repositoryWrapper.ClientRepository.GetAsync(include : Include(),
                                                                          pageNumber : pagination.PageNumber, pageSize : pagination.PageSize));
            }
            return(await _repositoryWrapper.ClientRepository.GetAsync(include : Include()));
        }
Ejemplo n.º 7
0
        private static Expression <Func <Client, bool> > Filter(ClientsFilter filter)
        {
            var expressionsList = new List <Expression <Func <Client, bool> > >();

            if (filter.UserId != null)
            {
                Expression <Func <Client, bool> > idFilter = a => a.UserId == filter.UserId;
                expressionsList.Add(idFilter);
            }

            if (filter.UserName != null)
            {
                Expression <Func <Client, bool> > usernameFilter = a => a.User.UserName == filter.UserName;
                expressionsList.Add(usernameFilter);
            }

            if (filter.IsDeleted != null)
            {
                Expression <Func <Client, bool> > userFilter = a => a.User.IsDeleted == filter.IsDeleted.Value;
                expressionsList.Add(userFilter);
            }

            if (filter.IsDeleted == null)
            {
                Expression <Func <Client, bool> > userFilter = a => !a.User.IsDeleted;
                expressionsList.Add(userFilter);
            }

            Expression <Func <Client, bool> > expression = animal => true;

            foreach (var exp in expressionsList)
            {
                expression = expression.AndAlso(exp);
            }

            return(expression);
        }