Пример #1
0
        public ActionResult AutoIndex()
        {
            //return View(TaxiDbContext.ReturnListAll<AutoModel>("Select * from public.\"Auto\"").ToList());
            List <AutoModel> autoModel = TaxiDbContext.ReturnListAll <AutoModel>("Select * from public.\"Auto\"").ToList();

            return(Json(new { data = autoModel }, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public ActionResult DriverIndex()
        {
            List <DriverModel> driverModel = TaxiDbContext.ReturnListAll <DriverModel>("SELECT * FROM public.\"Driver\"").ToList();

            foreach (DriverModel m in driverModel)
            {
                m.AutoModels = TaxiDbContext.ReturnListAll <AutoModel>("Select * from public.\"Auto\" where \"AutoId\" = " + m.AutoId).ToList();
            }

            return(Json(new { data = driverModel }, JsonRequestBehavior.AllowGet));
        }
Пример #3
0
 public ActionResult AutoDataEdit(int id = 0)
 {
     if (id == 0)
     {
         return(View());
     }
     else
     {
         return(View(TaxiDbContext.ReturnListAll <AutoModel>("Select * from public.\"Auto\" Where \"AutoId\" = " + id)
                     .FirstOrDefault <AutoModel>()));
     }
 }
Пример #4
0
        public ActionResult DriverDataEdit(int id = 0)
        {
            if (id == 0)
            {
                try
                {
                    DriverModel driverModel = new DriverModel();

                    var autoModels = TaxiDbContext.ReturnListAll <AutoModel>
                                         ("Select * from public.\"Auto\"").ToList();

                    var car = autoModels
                              .Select(x => new
                    {
                        AutoId = x.AutoId,
                        Brand  = x.Brand + " " + x.Model
                    });

                    ViewBag.AutoID = new SelectList(car, "AutoId", "Brand");

                    return(View(driverModel));
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else
            {
                DriverModel driverModel = TaxiDbContext.ReturnListAll <DriverModel>
                                              ("Select * from public.\"Driver\" Where \"Id\" = " + id).FirstOrDefault <DriverModel>();
                driverModel.AutoModels = TaxiDbContext.ReturnListAll <AutoModel>
                                             ("Select * from public.\"Auto\"").ToList();
                return(View(driverModel));
            }
        }
Пример #5
0
        public ActionResult GetAutoList()
        {
            var cars = TaxiDbContext.ReturnListAll <AutoModel>("Select * from public.\"Auto\"").ToList();

            return(Json(cars, JsonRequestBehavior.AllowGet));
        }