private bool BuildGoods(TransferViewGoods 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 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(); goods.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(); goods.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; }
private ActionResult PublishGoods(TransferViewGoods goods, List<HttpPostedFileBase> facefile, List<HttpPostedFileBase> otherfile, List<HttpPostedFileBase> badfile) { if (BuildGoods(goods, facefile, otherfile, badfile)) { GoodsTransferInfo transfergoods = MapperGoods(goods); transferService.SaveTransferGoods(transfergoods); RunJob(); FxCacheService.FxSite.GlobalCache cache = System.Web.Mvc.DependencyResolver.Current.GetService<FxCacheService.FxSite.GlobalCache>(); cache.InfoPublishAllCountAdd(); return View("Success"); } return View("FaildTransfer"); }
private GoodsTransferInfo MapperGoods(TransferViewGoods goods) { var info = new GoodsTransferInfo(); 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; }
public ActionResult Other(TransferViewGoods goods, List<HttpPostedFileBase> facefile, List<HttpPostedFileBase> otherfile, List<HttpPostedFileBase> badfile) { return PublishGoods(goods, facefile, otherfile, badfile); }