Exemplo n.º 1
0
 public ActionResult Delete(int?id)
 {
     Models.Goods art = db.Goodss.Find(id);
     db.Goodss.Remove(art);
     db.SaveChanges();
     return(RedirectToAction("MyIndexList"));
 }
Exemplo n.º 2
0
 [Filter.IsPostFromThisSite] //验证是否本机提交
 public ActionResult Add(Models.Goods model)
 {
     model.CreatDate   = DateTime.Now;
     model.ClickNum    = 0;
     model.State       = 0;
     model.Description = Sanitizer.GetSafeHtmlFragment(model.Description);
     //安装 AntiXSS 插件 去掉危险标签
     if (Session["UserID"] == null)
     {
         FormsAuthentication.SignOut();//清除假登陆状态
         return(RedirectToAction("Login", "User"));
     }
     else
     {
         model.UserID = int.Parse(Session["UserID"].ToString()); //获取作者id
         if (ModelState.IsValid)                                 //执行服务端的验证
         {
             db.Goodss.Add(model);                               //增加
             db.SaveChanges();                                   //保y
             return(RedirectToAction("MyIndexList"));
         }
         else
         {
             ModelState.AddModelError("Error", "添加失败,请重填");//
             setContent();
             return(View());
         }
     }
 }
Exemplo n.º 3
0
        public ActionResult EditState(int?id, int?state)
        {
            Models.Goods art    = db.Goodss.Find(id);
            int          state1 = state ?? 0;

            art.State           = state1;
            db.Entry(art).State = EntityState.Modified;
            db.SaveChanges();
            return(Content("ok"));
        }
Exemplo n.º 4
0
 public ActionResult Detail(int?id)
 {
     ViewData["EnumStyle1"] = new SelectList(EnumExt.ToListItem <Style1>(), "text", "text");
     Models.Goods art = db.Goodss.Find(id);
     if (art != null)
     {
         art.ClickNum        = art.ClickNum + 1; //修改点击率
         db.Entry(art).State = EntityState.Modified;
         db.SaveChanges();                       //保存修改
     }
     return(View(art));
 }
Exemplo n.º 5
0
        public CollectListModel(Models.Goods model)
        {
            Id            = model.Id;
            Name          = model.Name;
            OriginalPrice = model.OriginalPrice;
            ShopPrice     = model.ShopPrice;
            SalesVolume   = model.SalesVolume;
            PaymentAmount = model.PaymentAmount;
            Status        = model.Status == Models.GoodsStatus.InSale?1:0;
            var fileService = HostConstObject.Container.Resolve <IStorageFileService>();
            var mainImage   = fileService.GetFiles(model.Id, MallModule.Key, "MainImage").FirstOrDefault();

            MainImage = mainImage?.Simplified();
        }
 public IActionResult OnGet(string id = "")
 {
     Goods = new Models.Goods();
     if (!string.IsNullOrEmpty(id))
     {
         var criteria = new Core.Models.Goods.Criteria(id, string.Empty);
         var goods    = _goodsRepo.Get(criteria).FirstOrDefault();
         Goods = new Models.Goods
         {
             Id    = goods?.ID,
             Name  = goods?.GoodsName,
             Price = goods?.GoodsPrice ?? 0
         };
     }
     return(Page());
 }