Beispiel #1
0
        public ActionResult Recive(int?Car_Id, DateTime Start_Recive_Date, DateTime End_Recive_Date)
        {
            /*check by Cars number*/
            var        Cars_Recived = db.Cars.FirstOrDefault(car => car.Car_Id == Car_Id);
            ReciveDate reciveDate   = new ReciveDate();

            reciveDate.Start_Recive_Date = Start_Recive_Date;
            reciveDate.End_Recive_Date   = End_Recive_Date;
            reciveDate.cars = Cars_Recived;
            Dates_For_Car Date = new Dates_For_Car();

            Date.Start_Recive = (from Dates in db.ReciveDates
                                 where (Dates.cars.Car_Id == Cars_Recived.Car_Id)
                                 select
                                 (
                                     Dates.Start_Recive_Date
                                 )).ToList();
            Date.End_Recive = (from Dates in db.ReciveDates
                               where (Dates.cars.Car_Id == Cars_Recived.Car_Id)
                               select
                               (
                                   Dates.End_Recive_Date
                               )).ToList();



            foreach (var start in Date.Start_Recive)
            {
                foreach (var end in Date.End_Recive)
                {
                    if ((Start_Recive_Date >= start) && (End_Recive_Date <= end))
                    {
                        return(View("Recive_Alredy_Done", Cars_Recived));   //display Cars is Elredy recirved}
                    }
                    else
                    {
                        continue;
                    }
                }
            }


            string client_id = User.Identity.GetUserId();
            Client CLIENT    = db.Client.FirstOrDefault(client_ => client_.Client_ID == client_id);

            reciveDate.client = CLIENT;
            Calc_price(reciveDate);
            Cars_Recived.reciveDates.Add(reciveDate);
            CLIENT.Booked_Car.Add(reciveDate);
            db.SaveChanges();
            ViewBag.startDate = Start_Recive_Date;
            ViewBag.endDate   = End_Recive_Date;
            ViewBag.client    = CLIENT.Name;


            return(View("Displa_Reciving", Cars_Recived));   // display confirm for client recived done
        }
Beispiel #2
0
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Car car = db.Cars.FirstOrDefault(Car_ => Car_.Car_Id == id);
            cars_and_properties cars_And_Properties = new cars_and_properties();

            cars_And_Properties.Property_Name =
                (from car_ in db.Car_And_Properites
                 where (car_.Cars.Car_Id == car.Car_Id)
                 select(
                     car_.properties.proprity_Name
                     )).ToList();

            Dates_For_Car Date = new Dates_For_Car();

            Date.Start_Recive = (from Dates in db.ReciveDates
                                 where (Dates.cars.Car_Id == car.Car_Id)
                                 select
                                 (
                                     Dates.Start_Recive_Date
                                 )).ToList();
            Date.End_Recive = (from Dates in db.ReciveDates
                               where (Dates.cars.Car_Id == car.Car_Id)
                               select
                               (
                                   Dates.End_Recive_Date
                               )).ToList();
            Date.Clients = (from Dates in db.ReciveDates
                            where (Dates.cars.Car_Id == car.Car_Id)
                            select
                            (
                                Dates.client
                            )).ToList();
            Agince agince = (from ca in db.Cars
                             from ag in db.Agince
                             where (ag.Agince_ID == ca.Agince_Of_Car.Agince_ID)
                             select(ag)).FirstOrDefault();

            ViewBag.Agince = agince;
            ViewBag.list_of_Recived_Date = Date;
            ViewBag.list_of_properties   = cars_And_Properties;

            if (car == null)
            {
                return(HttpNotFound());
            }
            return(View(car));
        }