Пример #1
0
 public ActionResult Create(goodsview goods)
 {
     if (ModelState.IsValid)
     {
         var model = new goods
         {
             GoodsName        = goods.GoodsName,
             Brokerage        = goods.Brokerage,
             zkprice          = goods.zkprice,
             BrokerageExplain = goods.BrokerageExplain,
             Code             = goods.Code,
             DetailPath       = goods.DetailPath,
             ImagePath        = string.Join(",", goods.ImagePath.Images),
             IncomeRatio      = goods.IncomeRatio,
             Postage          = goods.Postage,
             SalesVolume      = goods.SalesVolume,
             SmallImages      = string.Join(",", goods.SamllImages.Images),
             Price            = goods.Price,
             ByIndex          = goods.ByIndex,
             GoodsState       = goods.GoodsState,
             Stock            = goods.Stock,
             Brand            = goods.Brand,
             GetPath          = goods.GetPath,
             IsRecommend      = goods.IsRecommend,
             Specs            = goods.Specs,
             SendAddress      = goods.SendAddress
         };
         db.goods.Add(model);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(goods));
 }
Пример #2
0
        public ActionResult Edit(goodsview goods)
        {
            if (ModelState.IsValid)
            {
                var t = db.goods.FirstOrDefault(s => s.ID == goods.ID);
                t.ID               = goods.ID;
                t.GoodsName        = goods.GoodsName;
                t.ImagePath        = string.Join(",", goods.ImagePath.Images);
                t.SmallImages      = string.Join(",", goods.SamllImages.Images);
                t.Stock            = goods.Stock;
                t.Brokerage        = goods.Brokerage;
                t.BrokerageExplain = goods.BrokerageExplain;
                t.Code             = goods.Code;
                t.DetailPath       = goods.DetailPath;
                t.IncomeRatio      = goods.IncomeRatio;
                t.Postage          = goods.Postage;
                t.Price            = goods.Price;
                t.SalesVolume      = goods.SalesVolume;
                t.zkprice          = goods.zkprice;
                t.ByIndex          = goods.ByIndex;
                t.GoodsState       = goods.GoodsState;
                t.Brand            = goods.Brand;
                t.Specs            = goods.Specs;
                t.IsRecommend      = goods.IsRecommend;
                t.GetPath          = goods.GetPath;
                t.SendAddress      = goods.SendAddress;
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            return(View(goods));
        }
Пример #3
0
        // GET: goods/Create
        public ActionResult Create()
        {
            ViewBag.Brand = new SelectList(db.Brand, "ID", "Name");
            var model = new goodsview();

            return(View(model));
        }
Пример #4
0
        // GET: goods/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            goods model  = db.goods.Find(id);
            var   models = new goodsview
            {
                ID               = model.ID,
                GoodsName        = model.GoodsName,
                Price            = model.Price,
                Stock            = model.Stock,
                Brokerage        = model.Brokerage,
                BrokerageExplain = model.BrokerageExplain,
                Code             = model.Code,
                zkprice          = model.zkprice,
                DetailPath       = model.DetailPath,
                IncomeRatio      = model.IncomeRatio,
                Postage          = model.Postage,
                SalesVolume      = model.SalesVolume,
                ByIndex          = model.ByIndex,
                GoodsState       = model.GoodsState,
                GetPath          = model.GetPath,
                IsRecommend      = model.IsRecommend,
                Brand            = model.Brand,
                Specs            = model.Specs,
                SendAddress      = model.SendAddress
            };

            models.ImagePath.Images   = model.ImagePath?.Split(',') ?? new string[0];
            models.SamllImages.Images = model.SmallImages?.Split(',') ?? new string[0];
            ViewBag.GoodsType         = new SelectList(db.goodstype.OrderBy(s => s.ID), "ID", "Name", models.GoodsType);
            ViewBag.Brand             = new SelectList(db.Brand.OrderBy(s => s.ID), "ID", "Name", models.Brand);
            if (model == null)
            {
                return(HttpNotFound());
            }
            return(View(models));
        }