Пример #1
0
        public ActionResult filterCars([FromForm] filterCarsForm form)
        {
            string             dateP    = form.pickupTime;
            string             dateR    = form.returnTime;
            List <Car>         allCars  = new List <Car>();
            List <FormRequest> requests = new List <FormRequest>();

            allCars  = _service.GetAllCars();
            requests = _service.GetReqByDate(form.pickupDate);
            Console.WriteLine(form.pickupDate);
            Console.WriteLine("Am gasit:" + requests.Count);
            DateTime dateTimePickup = DateTime.ParseExact(form.pickupTime, "HH:mm",
                                                          CultureInfo.InvariantCulture);
            DateTime dateTimeReturn = DateTime.ParseExact(form.returnTime, "HH:mm",
                                                          CultureInfo.InvariantCulture);


            do
            {
                Console.WriteLine(dateP);
                foreach (FormRequest req in requests)
                {
                    if (req.pickupTime == dateP)
                    {
                        Console.WriteLine("egal");
                        Car car = allCars.Single(r => r.nr_inmatriculare == req.car);
                        allCars.Remove(car);
                        foreach (var c in allCars)
                        {
                            Console.WriteLine(c.nr_inmatriculare);
                        }
                    }
                }
                DateTime newDate = DateTime.ParseExact(dateP, "HH:mm",
                                                       CultureInfo.InvariantCulture).AddHours(0.5);
                dateP = newDate.ToString("HH:mm", CultureInfo.CurrentCulture);
                Console.WriteLine("-----------");
            }while(dateP.CompareTo(dateR) != 0);

            return(Ok(allCars));
        }