Ejemplo n.º 1
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"));
        }
Ejemplo n.º 2
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));
        }