コード例 #1
0
        private List <ClientStatusDTO> FilterByComment(string Comment)
        {
            BillingSystemContext context = new BillingSystemContext();


            List <Client> clients = context.Clients.Include(c => c.ClientZone).Include(c => c.ClientTarif)
                                    .Where(c => c.Comment.ToLower()
                                           .Contains(Comment.ToLower())).ToList();

            List <ClientStatusDTO> clientsDTO = new List <ClientStatusDTO>();

            foreach (Client c in clients)
            {
                ClientStatusDTO newClient = (ClientStatusDTO)ModelToDto <ClientStatusDTO>(c);


                if (newClient.Validity >= DateTime.Now)
                {
                    newClient.Status = "ACTIVE";
                }
                else
                {
                    newClient.Status = "INACTIVE";
                }
                clientsDTO.Add(newClient);
            }

            return(clientsDTO);
        }
コード例 #2
0
        public List <ClientStatusDTO> GetInActiveClients()
        {
            BillingSystemContext context = new BillingSystemContext();

            context.Clients.Where(c => c.Validity < DateTime.Now).ToList();

            List <Client> clients = context
                                    .Clients.Include(c => c.ClientTarif)
                                    .Include(c => c.ClientZone)
                                    .ToList();

            List <ClientStatusDTO> clientsDTO = new List <ClientStatusDTO>();

            foreach (Client c in clients)
            {
                ClientStatusDTO newClient = (ClientStatusDTO)ModelToDto <ClientStatusDTO>(c);


                if (newClient.Validity >= DateTime.Now)
                {
                    newClient.Status = "ACTIVE";
                }
                else
                {
                    newClient.Status = "INACTIVE";
                }
                clientsDTO.Add(newClient);
            }

            return(clientsDTO);
        }
コード例 #3
0
        public IActionResult ClientDetails(int ID)
        {
            ClientsBLL      clientsBLL = new ClientsBLL();
            ClientStatusDTO client     = clientsBLL.GetClient(ID);


            if (client == null)
            {
                NotFound();
            }

            return(View(client));
        }
コード例 #4
0
        public ClientStatusDTO GetClient(int ID)
        {
            BillingSystemContext context = new BillingSystemContext();
            Client client = context.Clients
                            .Include(c => c.ClientTarif)
                            .Include(c => c.ClientZone)
                            .FirstOrDefault(c => c.IDNumber == ID);

            ClientStatusDTO clientDto = (ClientStatusDTO)ModelToDto <ClientStatusDTO>(client);


            return(clientDto);
        }
コード例 #5
0
        public List <ClientStatusDTO> GetFilteredClients(ClientFilterType FilterType, string Filter)
        {
            if (FilterType == ClientFilterType.Name)
            {
                BillingSystemContext context = new BillingSystemContext();
                List <Client>        clients = context
                                               .Clients.Include(c => c.ClientTarif)
                                               .Include(c => c.ClientZone)
                                               .ToList();

                List <ClientStatusDTO> clientsDTO = new List <ClientStatusDTO>();
                foreach (Client c in clients)
                {
                    ClientStatusDTO newClient = (ClientStatusDTO)ModelToDto <ClientStatusDTO>(c);

                    if (newClient.Validity >= DateTime.Now)
                    {
                        newClient.Status = "ACTIVE";
                    }
                    else
                    {
                        newClient.Status = "INACTIVE";
                    }
                    clientsDTO.Add(newClient);
                }
                FilterByName(Filter);
                return(clientsDTO);
            }
            else if (FilterType == ClientFilterType.Address)
            {
                BillingSystemContext context = new BillingSystemContext();

                List <Client> clients = context
                                        .Clients.Include(c => c.ClientTarif)
                                        .Include(c => c.ClientZone)
                                        .ToList();

                List <ClientStatusDTO> clientsDTO = new List <ClientStatusDTO>();

                foreach (Client c in clients)
                {
                    ClientStatusDTO newClient = (ClientStatusDTO)ModelToDto <ClientStatusDTO>(c);


                    if (newClient.Validity >= DateTime.Now)
                    {
                        newClient.Status = "ACTIVE";
                    }
                    else
                    {
                        newClient.Status = "INACTIVE";
                    }
                    clientsDTO.Add(newClient);
                }
                FilterByAddress(Filter);
                return(clientsDTO);
            }
            else if (FilterType == ClientFilterType.PhoneNumber)
            {
                BillingSystemContext context = new BillingSystemContext();

                List <Client> clients = context
                                        .Clients.Include(c => c.ClientTarif)
                                        .Include(c => c.ClientZone)
                                        .ToList();

                List <ClientStatusDTO> clientsDTO = new List <ClientStatusDTO>();

                foreach (Client c in clients)
                {
                    ClientStatusDTO newClient = (ClientStatusDTO)ModelToDto <ClientStatusDTO>(c);


                    if (newClient.Validity >= DateTime.Now)
                    {
                        newClient.Status = "ACTIVE";
                    }
                    else
                    {
                        newClient.Status = "INACTIVE";
                    }
                    clientsDTO.Add(newClient);
                }
                FilterByPhoneNumber(Filter);
                return(clientsDTO);
            }
            else if (FilterType == ClientFilterType.IPAdress)
            {
                BillingSystemContext context = new BillingSystemContext();

                List <Client> clients = context
                                        .Clients.Include(c => c.ClientTarif)
                                        .Include(c => c.ClientZone)
                                        .ToList();

                List <ClientStatusDTO> clientsDTO = new List <ClientStatusDTO>();

                foreach (Client c in clients)
                {
                    ClientStatusDTO newClient = (ClientStatusDTO)ModelToDto <ClientStatusDTO>(c);


                    if (newClient.Validity >= DateTime.Now)
                    {
                        newClient.Status = "ACTIVE";
                    }
                    else
                    {
                        newClient.Status = "INACTIVE";
                    }
                    clientsDTO.Add(newClient);
                }
                FilterByIPAdress(Filter);
                return(clientsDTO);
            }
            else if (FilterType == ClientFilterType.comment)
            {
                BillingSystemContext context = new BillingSystemContext();

                List <Client> clients = context
                                        .Clients.Include(c => c.ClientTarif)
                                        .Include(c => c.ClientZone)
                                        .ToList();

                List <ClientStatusDTO> clientsDTO = new List <ClientStatusDTO>();

                foreach (Client c in clients)
                {
                    ClientStatusDTO newClient = (ClientStatusDTO)ModelToDto <ClientStatusDTO>(c);


                    if (newClient.Validity >= DateTime.Now)
                    {
                        newClient.Status = "ACTIVE";
                    }
                    else
                    {
                        newClient.Status = "INACTIVE";
                    }
                    clientsDTO.Add(newClient);
                }
                FilterByComment(Filter);
                return(clientsDTO);
            }
            throw new InvalidEnumArgumentException("No such filter type.");
        }