Ejemplo n.º 1
0
        public ActionResult Create(TypeOfGoodsVM v)
        {
            TypeOfGood t = new TypeOfGood();

            int max = (from d in db.TypeOfGoods orderby d.TypeOfGoodID descending select d.TypeOfGoodID).FirstOrDefault();

            if (max == null)
            {
                t.TypeOfGoodID = 1;
                t.TypeOfGood1  = v.TypeOfGood;
            }
            else
            {
                t.TypeOfGoodID = max + 1;
                t.TypeOfGood1  = v.TypeOfGood;
            }

            if (ModelState.IsValid)
            {
                db.TypeOfGoods.Add(t);
                db.SaveChanges();
                TempData["SuccessMsg"] = "You have successfully added Type Of Goods.";
                return(RedirectToAction("Index"));
            }

            return(View());
        }
Ejemplo n.º 2
0
        public ActionResult Index()
        {
            List <TypeOfGoodsVM> lst = new List <TypeOfGoodsVM>();
            var data = db.TypeOfGoods.ToList();

            foreach (var item in data)
            {
                TypeOfGoodsVM v = new TypeOfGoodsVM();
                v.TypeOfGoodID = item.TypeOfGoodID;
                v.TypeOfGood   = item.TypeOfGood1;
                lst.Add(v);
            }
            return(View(lst));
        }
Ejemplo n.º 3
0
        //
        // GET: /TypeOfGood/Edit/5

        public ActionResult Edit(int id)
        {
            TypeOfGoodsVM v    = new TypeOfGoodsVM();
            var           data = (from d in db.TypeOfGoods where d.TypeOfGoodID == id select d).FirstOrDefault();

            if (data == null)
            {
                return(HttpNotFound());
            }
            else
            {
                v.TypeOfGoodID = data.TypeOfGoodID;
                v.TypeOfGood   = data.TypeOfGood1;
            }
            return(View(v));
        }
Ejemplo n.º 4
0
        public ActionResult Edit(TypeOfGoodsVM data)
        {
            TypeOfGood v = new TypeOfGood();

            v.TypeOfGoodID = data.TypeOfGoodID;
            v.TypeOfGood1  = data.TypeOfGood;

            if (ModelState.IsValid)
            {
                db.Entry(v).State = EntityState.Modified;
                db.SaveChanges();
                TempData["SuccessMsg"] = "You have successfully Updated Type Of Goods.";
                return(RedirectToAction("Index"));
            }
            return(View());
        }