Пример #1
0
        public ActionResult Create([Bind(Include = "Route_ID,Departure,Destination,Date,Airplane_ID")] Route route)
        {
            if (ModelState.IsValid)
            {
                db.Route.Add(route);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Airplane_ID = new SelectList(db.Airplane, "Airplane_ID", "Plane_Type", route.Airplane_ID);
            return(View(route));
        }
Пример #2
0
        public IHttpActionResult DeleteTableKucun(string goodsName)
        {
            testEntities1 testEntities1Obj = new testEntities1();

            testEntities1Obj.Configuration.ProxyCreationEnabled = false;
            List <kucun> list = testEntities1Obj.kucun.ToList();

            kucun obj1 = testEntities1Obj.kucun.Find(goodsName);

            //kucun obj = new kucun()
            //{
            //	商品名称 = data
            //};
            testEntities1Obj.Entry <kucun>(obj1).State = EntityState.Deleted;
            int res = testEntities1Obj.SaveChanges();

            if (res > 0)
            {
                return(Json(new { action = true }));
            }
            else
            {
                return(Json(new { action = false }));
            }
        }
Пример #3
0
        public IHttpActionResult UpdateTableKucun1(string goodsName, int goodsNum)
        {
            testEntities1 testEntities1Obj = new testEntities1();

            testEntities1Obj.Configuration.ProxyCreationEnabled = false;
            List <kucun> list = testEntities1Obj.kucun.ToList();


            kucun obj1 = testEntities1Obj.kucun.Find(goodsName);

            obj1.数量 = goodsNum;
            //string[] data = new string[2];
            //kucun obj = new kucun()
            //{
            //	商品名称 = goodsName,
            //	数量 = goodsNum
            //};
            //testEntities1Obj.Entry<kucun>(obj).State = EntityState.Modified;
            int res = testEntities1Obj.SaveChanges();

            if (res > 0)
            {
                return(Json(new { action = true }));
            }
            else
            {
                return(Json(new { action = false }));
            }
        }
        public bool SaveProduct(ProductDetailsModel pod)
        {
            productDetail pd = new productDetail();

            pd.ProductName    = pod.ProductName;
            pd.ProductDetails = pod.ProductDetails;
            pd.ProductType    = pod.ProductType;
            _dbContext.productDetails.Add(pd);
            if (_dbContext.SaveChanges() == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public object Delete(int id)
        {
            var db = new testEntities1();
            var x = db.TestUsers.ToList();
            TestUser currUser = x.Where(s => s.Id.Equals(id)).FirstOrDefault();
            if(currUser != null)
                db.TestUsers.Remove(currUser);

            db.SaveChanges();

            return new { error = "no error" };
        }
Пример #6
0
        public ActionResult Guardar(int diio, string nombre, string sexo, string raza, int edad, string tipo, string rebaño)
        {
            VACAS vacas = new VACAS()
            {
                diio   = diio,
                nombre = nombre,
                sexo   = sexo,
                raza   = raza,
                edad   = edad,
                tipo   = tipo,
                rebaño = rebaño
            };

            cnx.VACAS.Add(vacas);
            cnx.SaveChanges();
            return(View("Listado", cnx.VACAS.ToList()));
        }
 public void UpdateUser(int id, [FromBody]TestUser value)
 {
     var db = new testEntities1();
     var x = db.TestUsers.ToList();
     TestUser currUser = x.Where(s => s.Id.Equals(id)).FirstOrDefault();
     if (currUser != null)
     {
         currUser.FirstName = value.FirstName;
         currUser.LastName = value.LastName;
         currUser.StreetNumber = value.StreetNumber;
         currUser.StreetName = value.StreetName;
         currUser.Email = value.Email;
         currUser.State = value.State;
         currUser.CitySuburb = value.CitySuburb;
         currUser.Postcode = value.Postcode;
     }
     db.SaveChanges();
 }
Пример #8
0
        public JsonResult DeleteTableKucun(string data)
        {
            kucun obj = new kucun()
            {
                商品名称 = data,
            };
            testEntities1 testentities1obj = new testEntities1();

            testentities1obj.Entry <kucun>(obj).State = EntityState.Deleted;
            int res = testentities1obj.SaveChanges();

            if (res > 0)
            {
                return(Json(new { action = true }));
            }
            else
            {
                return(Json(new { action = false }));
            }
        }
Пример #9
0
        public IHttpActionResult InsertinTableKucun(string goodsName, int goodsNum)
        {
            kucun obj = new kucun()
            {
                商品名称 = goodsName,
                数量   = goodsNum
            };
            testEntities1 testEntities1Obj = new testEntities1();

            testEntities1Obj.kucun.Add(obj);
            int res = testEntities1Obj.SaveChanges();

            if (res > 0)
            {
                return(Json(new { action = true }));
            }
            else
            {
                return(Json(new { action = false }));
            }
        }
Пример #10
0
        public JsonResult InsertinTableKucun(string[] data)
        {
            kucun obj = new kucun()
            {
                商品名称 = data[0],
                数量   = int.Parse(data[1])
            };
            testEntities1 testEntities1Obj = new testEntities1();

            testEntities1Obj.kucun.Add(obj);
            int res = testEntities1Obj.SaveChanges();

            if (res > 0)
            {
                return(Json(new { action = true }));
            }
            else
            {
                return(Json(new { action = false }));
            }
        }
Пример #11
0
        public JsonResult UpdateTableKucun(string[] data)
        {
            kucun obj = new kucun()
            {
                商品名称 = data[0],
                数量   = int.Parse(data[1])
            };
            testEntities1 testentities1obj = new testEntities1();

            testentities1obj.Entry <kucun>(obj).State = EntityState.Modified;
            int res = testentities1obj.SaveChanges();

            if (res > 0)
            {
                return(Json(new { action = true }));
            }
            else
            {
                return(Json(new { action = false }));
            }
        }
 public void AddUsers([FromBody]TestUser value)
 {
     var db = new testEntities1();
     db.TestUsers.Add(value);
     db.SaveChanges();
 }