public async Task <ActionResult> CreateTec(string id) { if (id != null) { TrustTecDet detal = await repo.Get(id); return(View(detal)); } return(View(new TrustTecDet())); }
public async Task <TrustTecDet> Get(string gn) { Transport trans = await db.Transports.Where(t => (Int32)t.CustID == (Int32)custID).FirstOrDefaultAsync(o => o.Gn == gn); TrustTecDet tecDet = new TrustTecDet(); tecDet.Driv = trans.Driv; tecDet.Gn = trans.Gn; tecDet.TecModel = trans.TecModel; return(tecDet); }
public void delete(int id) { TrustTecDet tecDet = db.TrustTecDets.Find(id); TrustTec tec = db.TrustTecs.Find(tecDet.TrustTecId); int cnt = db.TrustTecDets.Count(c => c.TrustTecId == tec.TrustTecId); if (cnt < 2) { db.TrustTecs.Remove(tec); } db.TrustTecDets.Remove(tecDet); db.SaveChanges(); }
//public ActionResult CreateTec() //{ // TrustTecDet det; // det = new TrustTecDet(); // return View("CreateTec", det); //} //[HttpPost] //[ValidateAntiForgeryToken] //public ActionResult CreateTec(TrustTecDet det) //{ // TrustTecV tecV = (TrustTecV)Session["TrustTecV"]; // if (tecV.Detail == null) // tecV.Detail = new List<TrustTecDet>(); // tecV.Detail.Add(det); // Session["TrustTecV"] = tecV; // return RedirectToAction("Create"); //} public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TrustTecDet tecDet = await db.TrustTecDets.FindAsync(id); if (tecDet == null) { return(HttpNotFound()); } return(View(tecDet)); }
public async Task <ActionResult> CreateTec(TrustTecDet det) { if (ModelState.IsValid) { orderSes = (OrderSes)Session["OrdSes"]; OrderDriv drv = new OrderDriv(); drv.OrderId = orderSes.id; drv.Gn = det.Gn; drv.TecModel = det.TecModel; db.OrderDrivs.Add(drv); await db.SaveChangesAsync(); } return(RedirectToAction("Booking")); }
public ActionResult CreateTec(TrustTecDet det) { if (ModelState.IsValid) { List <TrustTecDet> tecs; if (Session["TecDet"] == null) { Session["TecDet"] = new List <TrustTecDet>(); } tecs = (List <TrustTecDet>)Session["TecDet"]; tecs.Add(det); Session["TecDet"] = tecs; return(RedirectToAction("Create")); } return(HttpNotFound()); }
public async Task <int> SaveDetail(TrustTecDet det) { TrustTec tec = new TrustTec(); tec.CustId = custID; tec.DatCreate = DateTime.Now; db.TrustTecs.Add(tec); int id = await db.SaveChangesAsync(); TrustTecDet tecDet = new TrustTecDet(); tecDet.TrustTecId = tec.TrustTecId; tecDet.TecModel = det.TecModel; tecDet.Gn = det.Gn; tecDet.Driv = det.Driv; db.TrustTecDets.Add(tecDet); int iddet = await db.SaveChangesAsync(); return(iddet); }
public async Task <int> SaveDetail(int id, List <TrustTecDet> det) { foreach (var item in det) { TrustTecDet tecDet = new TrustTecDet(); tecDet.TrustTecDetId = item.TrustTecDetId; tecDet.TrustTecId = id; tecDet.TecModel = item.TecModel; tecDet.Gn = item.Gn; tecDet.Driv = item.Driv; if (tecDet.TrustTecDetId == 0) { db.TrustTecDets.Add(tecDet); } else { db.Entry(tecDet).State = EntityState.Modified; } } int iddet = await db.SaveChangesAsync(); return(iddet); }