Exemplo n.º 1
0
        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"));
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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"));
        }