// GET: goodstypes/Edit/5
        public ActionResult Edit(int?id)
        {
            Sidebar();
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            goodstype model  = db.goodstype.Find(id);
            var       models = new goodstypeview
            {
                ID        = model.ID,
                Name      = model.Name,
                ParentID  = model.ParentID,
                SortIndex = model.SortIndex,
            };

            models.ImagePath.Images = model.ImagePath?.Split(',') ?? new string[0];
            ViewBag.ParentID        = new SelectList(db.goodstype.Where(s => s.ParentID != s.ID), "ID", "Name", models.ParentID);

            if (models == null)
            {
                return(HttpNotFound());
            }
            return(View(models));
        }
Пример #2
0
        public List <Order> inquiryOrder(goodstype goodstype)      //按商品名称查询
        {
            var query = orderList.Where(x => x.orderItemList.Exists(y => y.thisgoods.Type == goodstype))
                        .OrderByDescending(x => x.Totalprice);

            return(query.ToList());
        }
        public ActionResult DeleteConfirmed(int id)
        {
            goodstype goodstype = db.goodstype.Find(id);

            db.goodstype.Remove(goodstype);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public static List <Order> inquiryOrder(goodstype goodstype)
 {
     using (var db = new OrderContext())
     {
         var query = db.Orders
                     .Where(o => o.orderItemList.Exists(y => y.GoodsType == goodstype));
         return(query.ToList());
     }
 }
        // GET: goodstypes/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            goodstype goodstype = db.goodstype.Find(id);

            if (goodstype == null)
            {
                return(HttpNotFound());
            }
            return(View(goodstype));
        }
        public ActionResult Create(goodstypeview goodstype)
        {
            if (ModelState.IsValid)
            {
                var model = new goodstype
                {
                    Name      = goodstype.Name,
                    ImagePath = string.Join(",", goodstype.ImagePath.Images),
                    ParentID  = goodstype.ParentID,
                    SortIndex = goodstype.SortIndex
                };
                db.goodstype.Add(model);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(goodstype));
        }
Пример #7
0
 public Goods(goodstype type, double price)
 {
     this.type  = type;
     this.price = price;
 }
Пример #8
0
 public Goods(goodstype type) : this()
 {
     this.Type = type;
 }