Exemple #1
0
        public ActionResult IndexArchived(string searchTerm, int pageNumber = 1)
        {
            List <Vehicle> vehicles = new List <Vehicle>();

            if (String.IsNullOrEmpty(searchTerm))
            {
                vehicles = RepoVehicle.FindAllArchived();
            }
            else
            {
                if (int.TryParse(searchTerm, out int auction))
                {
                    Vehicle vhcByID = RepoVehicle.FindById(auction);
                    if (vhcByID != null)
                    {
                        vehicles.Add(vhcByID);
                    }
                }
                else
                {
                    vehicles = RepoVehicle.GetVehiclesByName(searchTerm, false);
                }
            }
            return(View(new PaginatedList <Vehicle>().CreateList(vehicles, pageNumber, PageSizeArchivedDefault)));
        }
Exemple #2
0
 private void RemoveVehiclesOlderThan(int days, int carLimit)
 {
     try
     {
         List <Vehicle> vehicleArchived = RepoVehicle.FindAllArchived();
         for (int i = 0; i < vehicleArchived.Count || i > carLimit; i++)
         {
             if (vehicleArchived[i].DateAuctionEnd.AddDays(days) < DateTime.Now)
             {
                 RepoVehicle.Delete(vehicleArchived[i]); //cascade deleting (images)
             }
         }
     }
     catch
     {
         //do nothing, app working is more important than removing
     }
 }