private ActionResult PublishCar(TransferViewCar car, List<HttpPostedFileBase> facefile, List<HttpPostedFileBase> otherfile, List<HttpPostedFileBase> badfile)
 {
     if (BuildCar(car, facefile, otherfile, badfile))
     {
         CarTransferInfo transfercar = MapperCar(car);
         transferService.SaveTransferCar(transfercar);
         RunJob();
         FxCacheService.FxSite.GlobalCache cache = System.Web.Mvc.DependencyResolver.Current.GetService<FxCacheService.FxSite.GlobalCache>();
         cache.InfoPublishAllCountAdd();
         return View("Success");
     }
     return View("FaildTransfer");
 }
 private CarTransferInfo MapperCar(TransferViewCar car)
 {
     var info = new CarTransferInfo();
     info.CarMileage = car.CarMileage;
     info.CarYear = car.CarYear;
     info.CatagroyId = car.CatagroyId;
     info.AreaId = car.AreaId;
     info.Controller = this.ControllerName;
     info.Action = this.ActionName;
     info.CityId = car.CityId;
     info.Mark = car.Mark;
     car.FaceFiles.ForEach(r => info.Pictures.Add(r));
     car.OtherFiles.ForEach(r => info.Pictures.Add(r));
     car.BadFiles.ForEach(r => info.Pictures.Add(r));
     info.Price = (int)car.Price;
     info.PublishTitle = car.Title;
     info.PublishUserEmail = car.Email;
     info.UserAccount = User.Identity.Name;
     return info;
 }
 public ActionResult CarAccessories(TransferViewCar car,
     List<HttpPostedFileBase> facefile, List<HttpPostedFileBase> otherfile, List<HttpPostedFileBase> badfile)
 {
     return PublishCar(car, facefile, otherfile, badfile);
 }
 public ActionResult SecondHandCar(TransferViewCar car,
     List<HttpPostedFileBase> facefile, List<HttpPostedFileBase> otherfile, List<HttpPostedFileBase> badfile)
 {
     return PublishCar(car, facefile, otherfile, badfile);
 }
        private bool BuildCar(TransferViewCar car, 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();
                    car.FaceFiles.Add(new TransferPicture()
                    {
                        ImageUrl = GetVirtualPath() + pictureName,
                        MinImageUrl = GetVirtualPath() + pictureMinName,
                        CdnUrl = "",
                        TransferPictureCatagroy = (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();
                    car.OtherFiles.Add(new TransferPicture()
                    {
                        ImageUrl = GetVirtualPath() + pictureName,
                        MinImageUrl = GetVirtualPath() + pictureMinName,
                        CdnUrl = "",
                        TransferPictureCatagroy = (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();
                    car.BadFiles.Add(new TransferPicture()
                    {
                        ImageUrl = GetVirtualPath() + pictureName,
                        MinImageUrl = GetVirtualPath() + pictureMinName,
                        CdnUrl = "",
                        TransferPictureCatagroy = (int)PictureCatagroy.Bad,
                        PhysicalPath = GetPhysicalPath() + pictureName
                    });
                    SaveFile(bad, GetPhysicalPath(), GetPhysicalPath() + pictureName);
                }
            }
            #endregion

            return true;
        }