コード例 #1
0
        // GET: Selides/Create
        public ActionResult Create()
        {
            Sidebar();
            var model = new SelideView();

            return(View(model));
        }
コード例 #2
0
 public ActionResult Create(SelideView selide)
 {
     if (ModelState.IsValid)
     {
         var model = new Selide
         {
             Title      = selide.Title,
             ImagePath  = string.Join(",", selide.ImagePath.Images),
             SelideType = selide.SelideType,
             Index      = selide.Index,
             GoodsID    = selide.GoodsID,
             GoodsName  = selide.GoodsName
         };
         db.Selide.Add(model);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(selide));
 }
コード例 #3
0
        public ActionResult Edit(SelideView selide)
        {
            Sidebar();
            if (ModelState.IsValid)
            {
                var t = db.Selide.FirstOrDefault(s => s.ID == selide.ID);
                t.ID         = selide.ID;
                t.Title      = selide.Title;
                t.Index      = selide.Index;
                t.SelideType = selide.SelideType;
                t.GoodsID    = selide.GoodsID;
                t.GoodsName  = selide.GoodsName;
                t.ImagePath  = string.Join(",", selide.ImagePath.Images);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            return(View(selide));
        }
コード例 #4
0
        // GET: Selides/Edit/5
        public ActionResult Edit(int?id)
        {
            Sidebar();
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Selide model  = db.Selide.Find(id);
            var    models = new SelideView
            {
                ID         = model.ID,
                Index      = model.Index,
                SelideType = model.SelideType,
                Title      = model.Title,
                GoodsID    = model.GoodsID,
                GoodsName  = model.GoodsName
            };

            models.ImagePath.Images = model.ImagePath?.Split(',') ?? new string[0];
            return(View(models));
        }