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); }
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); }
public IActionResult ClientDetails(int ID) { ClientsBLL clientsBLL = new ClientsBLL(); ClientStatusDTO client = clientsBLL.GetClient(ID); if (client == null) { NotFound(); } return(View(client)); }
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); }
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."); }