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)); }
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)); }
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>())); } }
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)); } }
public ActionResult GetAutoList() { var cars = TaxiDbContext.ReturnListAll <AutoModel>("Select * from public.\"Auto\"").ToList(); return(Json(cars, JsonRequestBehavior.AllowGet)); }