private GoodsBuyInfo MapperGoods(BuyViewGoods goods)
 {
     var info = new GoodsBuyInfo();
     info.CatagroyId = goods.CatagroyId;
     info.AreaId = goods.AreaId;
     info.ChangeMsg = goods.ChangeGoodsMsg;
     info.Controller = this.ControllerName;
     info.Action = this.ActionName;
     info.CityId = goods.CityId;
     info.GoodsConditionMsg = goods.GoodConditonMsg;
     info.GoodsconditonId = goods.GoodConditionId;
     info.IsChange = goods.IsChangeGoods;
     info.Mark = goods.Mark;
     goods.FaceFiles.ForEach(r => info.Pictures.Add(r));
     goods.OtherFiles.ForEach(r => info.Pictures.Add(r));
     goods.BadFiles.ForEach(r => info.Pictures.Add(r));
     info.Price = (int)goods.Price;
     info.PublishTitle = goods.Title;
     info.PublishUserEmail = goods.Email;
     info.UserAccount = User.Identity.Name;
     return info;
 }
 private ActionResult PublishGoods(BuyViewGoods goods, List<HttpPostedFileBase> facefile, List<HttpPostedFileBase> otherfile, List<HttpPostedFileBase> badfile)
 {
     if (BuildGoods(goods, facefile, otherfile, badfile))
     {
         GoodsBuyInfo transfergoods = MapperGoods(goods);
         buyService.SaveBuyGoods(transfergoods);
         RunJob();
         FxCacheService.FxSite.GlobalCache cache = System.Web.Mvc.DependencyResolver.Current.GetService<FxCacheService.FxSite.GlobalCache>();
         cache.InfoPublishAllCountAdd();
         return View("Success");
     }
     return View("FaildTransfer");
 }
        private bool BuildGoods(BuyViewGoods goods, List<HttpPostedFileBase> facefile, List<HttpPostedFileBase> otherfile, List<HttpPostedFileBase> badfile)
        {
            InitParas();
            string pictureName;
            string pictureMinName;
            //图片保存到
            #region FaceFile
            foreach (var face in facefile)
            {

                if (face.HasFile())
                {
                    pictureName = GetPictureName();
                    pictureMinName = GetPictureMinName();
                    goods.FaceFiles.Add(new BuyPicture()
                    {
                        ImageUrl = GetVirtualPath() + pictureName,
                        MinImageUrl = GetVirtualPath() + pictureMinName,
                        CdnUrl = "",
                        BuyPictureCatagroy = (int)PictureCatagroy.Head,
                        PhysicalPath = GetPhysicalPath() + pictureName
                    });
                    SaveFile(face, GetPhysicalPath(), GetPhysicalPath() + pictureName);
                }
            }
            #endregion

            #region OtherFile
            foreach (var other in otherfile)
            {
                if (other.HasFile())
                {
                    pictureName = GetPictureName();
                    pictureMinName = GetPictureMinName();
                    goods.OtherFiles.Add(new BuyPicture()
                    {
                        ImageUrl = GetVirtualPath() + pictureName,
                        MinImageUrl = GetVirtualPath() + pictureMinName,
                        CdnUrl = "",
                        BuyPictureCatagroy = (int)PictureCatagroy.Other,
                        PhysicalPath = GetPhysicalPath() + pictureName
                    });
                    SaveFile(other, GetPhysicalPath(), GetPhysicalPath() + pictureName);
                }
            }
            #endregion

            #region badFile
            foreach (var bad in badfile)
            {
                if (bad.HasFile())
                {
                    pictureName = GetPictureName();
                    pictureMinName = GetPictureMinName();
                    goods.BadFiles.Add(new BuyPicture()
                    {
                        ImageUrl = GetVirtualPath() + pictureName,
                        MinImageUrl = GetVirtualPath() + pictureMinName,
                        CdnUrl = "",
                        BuyPictureCatagroy = (int)PictureCatagroy.Bad,
                        PhysicalPath = GetPhysicalPath() + pictureName
                    });
                    SaveFile(bad, GetPhysicalPath(), GetPhysicalPath() + pictureName);
                }
            }
            #endregion
            return true;
        }
 public ActionResult Other(BuyViewGoods goods,
     List<HttpPostedFileBase> facefile, List<HttpPostedFileBase> otherfile, List<HttpPostedFileBase> badfile)
 {
     return PublishGoods(goods, facefile, otherfile, badfile);
 }