public IHttpActionResult PuttblRoad(int id, tblRoad tblRoad) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tblRoad.BIA_No) { return(BadRequest()); } db.Entry(tblRoad).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!tblRoadExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult update(int BIA_No, string Road_Name, string Miles, int Type_Id) { tblRoad table = new tblRoad(); using (var db = new RoadsEntities()) { table = db.tblRoads.First(em => em.BIA_No == BIA_No); } if (table != null) { table.Road_Name = Road_Name; table.Type_Id = Type_Id; table.Miles = Convert.ToDouble(Miles); } using (var dc = new RoadsEntities()) { dc.Entry(table).State = EntityState.Modified; dc.SaveChanges(); } ModelState.Clear(); return(RedirectToAction("Index")); }
public ActionResult EditingInline_Update([DataSourceRequest] DataSourceRequest request, TranViewModel tran) { RoadsEntities db = new RoadsEntities(); var t = db.tblTransactions.Where(tr => tr.AutoNumber.Equals(tran.AutoNumber)).FirstOrDefault(); t.Hours = tran.Hours; t.Lease_Chg = tran.Lease_Chg; db.SaveChanges(); return(Json(new[] { tran }.ToDataSourceResult(request, ModelState))); }
public ActionResult create(RoadViewModel tbl) { RoadsEntities db = new RoadsEntities(); tblRoad tb = new tblRoad(); tb.BIA_No = Convert.ToInt32(tbl.BIA_No); tb.Road_Name = tbl.Road_Name; tb.Miles = tbl.Miles; tb.Type_Id = tbl.Type_Id; db.tblRoads.Add(tb); db.SaveChanges(); ModelState.Clear(); return(Index()); }
public ActionResult AddTransaction(TranViewModel tvm) { using (RoadsEntities db = new RoadsEntities()) { tblTransaction tt = new tblTransaction(); tt.Trans_Date = tvm.Trans_Date; tt.Emp_No = tvm.Emp_no; tt.Mach_No = tvm.Mach_No; tt.BIA_No = tvm.BIA_No; tt.Activity_Code = tvm.Activity_Code; tt.Hours = tvm.Hours; tt.Lease_Chg = tvm.Lease_Chg; db.tblTransactions.Add(tt); db.SaveChanges(); ModelState.Clear(); } return(RedirectToAction("Index")); }
public ActionResult AddMachine(tblMach mac) { RoadsEntities dbCxt = new RoadsEntities(); //if (dbCxt.tblMaches.Select(m => m.Mach_No == mac.Mach_No) != null) //{ // ModelState.AddModelError("", "Cannot add duplicate Machine Code."); //} //else //{ using (RoadsEntities db = new RoadsEntities()) { db.tblMaches.Add(mac); db.SaveChanges(); ModelState.Clear(); } //} return(RedirectToAction("Index")); }
public ActionResult Update(int Mach_No, string Mach_Desc, double Lease_Rate, int Owner_Num, bool Active) { tblMach tblmach; using (db = new RoadsEntities()) { tblmach = db.tblMaches.First(m => m.Mach_No == Mach_No); } if (tblmach != null) { tblmach.Mach_Desc = Mach_Desc; tblmach.Lease_Rate = Lease_Rate; tblmach.Owner_Num = Owner_Num; tblmach.Active = Active; } using (var dbCtx = new RoadsEntities()) { dbCtx.Entry(tblmach).State = System.Data.Entity.EntityState.Modified; dbCtx.SaveChanges(); } ModelState.Clear(); return(RedirectToAction("Index")); }