Example #1
0
        public ActionResult EditVersion(ViewModelVersions version)
        {
            Versions saveVersions = new Versions
            {
                GoodsId         = version.GoodsId,
                VersionName     = version.VersionName,
                Price           = version.Price,
                VersionId       = version.VersionId,
                Stock           = version.Stock,
                ActivationTimes = version.ActivationTimes,
                Sell            = version.Sell,
                WarehouseId     = version.WarehouseId,
            };

            try
            {
                if (version.VersionImage != null)
                {
                    saveVersions.VersionImage = GetImageFromWeb();
                }
                else
                {
                    var ver = goodsService.GetVersionByVersionId(version.VersionId);
                    saveVersions.VersionImage = ver.VersionImage;
                }
            }
            catch
            {
                TempData["Error"] = "请填写必填项!!!";
                RedirectToAction("EditGoods", new { version.GoodsId });
            }
            if (version.VersionId == 0)
            {
                if (goodsService.AddVersion(saveVersions))
                {
                }
                else
                {
                    TempData["Error"] = "请填写必填项!!!";
                    RedirectToAction("EditGoods", new { version.GoodsId });
                }
            }
            else
            {
                if (goodsService.EditVersion(saveVersions))
                {
                }
                else
                {
                    TempData["Error"] = "请填写必填项!!!";
                    RedirectToAction("EditGoods", new { version.GoodsId });
                }
            }
            return(RedirectToAction("EditGoods", new { version.GoodsId }));
        }