Exemplo n.º 1
0
        public ActionResult UploadItem(Treasure treasure)
        {
            if (ModelState.IsValid)
            {
                #region 数据初始化
                treasure.BrowseNum  = 0;
                treasure.Favorite   = 0;
                treasure.UpdateTime = DateTime.Now;
                treasure.UploadTime = DateTime.Now;
                treasure.EditCount  = 0;
                treasure.Link       = "/Treasure/TreasureInfo?TreasureUID=" + treasure.TreasureUID.ToString();
                if (string.IsNullOrEmpty(treasure.Remarks))
                {
                    treasure.Remarks = "无";
                }
                #endregion
                repository.SaveTreasure(treasure);
                UploadImgs uploadImgs = new UploadImgs
                {
                    TreasureUID  = treasure.TreasureUID.ToString(),
                    UserID       = treasure.HolderID,
                    TreasureName = treasure.TreasureName
                };

                //再跳转到上传图片页面前,要先清空原来的图片路径
                if (DropListHelper.DeletePic(treasure.TreasureUID))
                {
                    return(View("UpLoadImg", uploadImgs));
                }
            }
            return(View(treasure));
        }
Exemplo n.º 2
0
 public ActionResult EditImg(string TreasureUID)
 {
     //清空图片
     if (DropListHelper.DeletePic(Guid.Parse(TreasureUID)))
     {
         Treasure treasure = repository.Treasures.Where(t => t.TreasureUID == Guid.Parse(TreasureUID)).FirstOrDefault();
         return(View(new UploadImgs
         {
             TreasureUID = TreasureUID,
             UserID = treasure.HolderID,
             TreasureName = treasure.TreasureName
         }));
     }
     return(View("Error"));
 }
Exemplo n.º 3
0
        public ActionResult Edit(Guid TreasureUID)
        {
            if (string.IsNullOrEmpty(TreasureUID.ToString()))
            {
                return(RedirectToAction("MyList", "Treasure"));
            }
            //获取当前用户的UID
            string HolderID = CurrentUser.Id;
            //验证用户UID,确保该物品是所属人在操作
            Treasure treasure = repository.Treasures.FirstOrDefault(t => t.TreasureUID == TreasureUID && t.HolderID == HolderID);

            //如果存在,转入编辑页面
            if (treasure != null)
            {
                #region 物品类别集合
                IEnumerable <SelectListItem> types = new List <SelectListItem>()
                {
                    new SelectListItem()
                    {
                        Text = "网络设备", Value = "网络设备"
                    },
                    new SelectListItem()
                    {
                        Text = "电脑配件", Value = "电脑配件"
                    },
                    new SelectListItem()
                    {
                        Text = "图书画册", Value = "图书画册"
                    },
                    new SelectListItem()
                    {
                        Text = "电子产品", Value = "电子产品"
                    },
                    new SelectListItem()
                    {
                        Text = "其他", Value = "其他"
                    }
                };
                types            = DropListHelper.SetDefault(types, treasure.TreasureType);
                Session["Types"] = types;
                #endregion

                #region 物品成色集合
                IEnumerable <SelectListItem> damageDegree = new List <SelectListItem>()
                {
                    new SelectListItem()
                    {
                        Text = "全新", Value = "全新"
                    },
                    new SelectListItem()
                    {
                        Text = "九八新", Value = "九八新"
                    },
                    new SelectListItem()
                    {
                        Text = "九五新", Value = "九五新"
                    },
                    new SelectListItem()
                    {
                        Text = "九成新", Value = "九成新"
                    },
                    new SelectListItem()
                    {
                        Text = "八五新", Value = "八五新"
                    },
                    new SelectListItem()
                    {
                        Text = "八成新", Value = "八成新"
                    },
                    new SelectListItem()
                    {
                        Text = "七成新", Value = "七成新"
                    },
                    new SelectListItem()
                    {
                        Text = "七成及以下", Value = "七成及以下"
                    },
                };
                damageDegree             = DropListHelper.SetDefault(damageDegree, treasure.DamageDegree);
                Session["DamageDegrees"] = damageDegree;
                #endregion

                #region 物品交易范围集合
                IEnumerable <SelectListItem> tradeRange = new List <SelectListItem>()
                {
                    new SelectListItem()
                    {
                        Text = "市内", Value = "市内"
                    },
                    new SelectListItem()
                    {
                        Text = "省内", Value = "省内"
                    },
                    new SelectListItem()
                    {
                        Text = "临近省", Value = "临近省"
                    },
                    new SelectListItem()
                    {
                        Text = "全国(港澳台除外)", Value = "全国"
                    },
                    new SelectListItem()
                    {
                        Text = "不限", Value = "不限"
                    }
                };
                tradeRange             = DropListHelper.SetDefault(tradeRange, treasure.TradeRange);
                Session["TradeRanges"] = tradeRange;
                #endregion

                return(View(treasure));
            }
            return(View("Error"));
        }
Exemplo n.º 4
0
        public ActionResult UploadItem()
        {
            #region 物品类别集合
            IEnumerable <SelectListItem> types = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text = "网络设备", Value = "网络设备"
                },
                new SelectListItem()
                {
                    Text = "电脑配件", Value = "电脑配件"
                },
                new SelectListItem()
                {
                    Text = "图书画册", Value = "图书画册"
                },
                new SelectListItem()
                {
                    Text = "电子产品", Value = "电子产品"
                },
                new SelectListItem()
                {
                    Text = "其他", Value = "其他"
                }
            };
            types            = DropListHelper.SetDefault(types, "其他");
            Session["Types"] = types;
            #endregion

            #region 物品成色集合
            IEnumerable <SelectListItem> damageDegree = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text = "全新", Value = "全新"
                },
                new SelectListItem()
                {
                    Text = "九八新", Value = "九八新"
                },
                new SelectListItem()
                {
                    Text = "九五新", Value = "九五新"
                },
                new SelectListItem()
                {
                    Text = "九成新", Value = "九成新"
                },
                new SelectListItem()
                {
                    Text = "八五新", Value = "八五新"
                },
                new SelectListItem()
                {
                    Text = "八成新", Value = "八成新"
                },
                new SelectListItem()
                {
                    Text = "七成新", Value = "七成新"
                },
                new SelectListItem()
                {
                    Text = "七成及以下", Value = "七成及以下"
                },
            };
            damageDegree             = DropListHelper.SetDefault(damageDegree, "全新");
            Session["DamageDegrees"] = damageDegree;
            #endregion

            #region 物品交易范围集合
            IEnumerable <SelectListItem> tradeRange = new List <SelectListItem>()
            {
                new SelectListItem()
                {
                    Text = "市内", Value = "市内"
                },
                new SelectListItem()
                {
                    Text = "省内", Value = "省内"
                },
                new SelectListItem()
                {
                    Text = "临近省", Value = "临近省"
                },
                new SelectListItem()
                {
                    Text = "全国(港澳台除外)", Value = "全国"
                },
                new SelectListItem()
                {
                    Text = "不限", Value = "不限"
                }
            };
            tradeRange             = DropListHelper.SetDefault(tradeRange, "不限");
            Session["TradeRanges"] = tradeRange;
            #endregion

            Treasure treasure = new Treasure()
            {
                TreasureUID = Guid.NewGuid(),
                HolderID    = CurrentUser.Id,
            };
            return(View(treasure));
        }