public ActionResult Edit(FormCollection formCollection, BannerViewModel vo)
        {
            var entity = _bannerRepo.GetItem(vo.Id);
            if (!ModelState.IsValid || entity==null)
            {
                ModelState.AddModelError("", "参数验证失败.");
                return View(vo);
            }
           

            entity.UpdatedDate = DateTime.Now;
            entity.UpdatedUser = base.CurrentUser.CustomerId;
            entity.Status = vo.Status;
            entity.SortOrder = vo.SortOrder;
            entity.SourceId = vo.SourceId;
         
            using (TransactionScope ts = new TransactionScope())
            {
                _bannerRepo.Update(entity);
                if (ControllerContext.HttpContext.Request.Files.Count > 0)
                {
                    foreach (string fileName in ControllerContext.HttpContext.Request.Files)
                    {
                        var file = ControllerContext.HttpContext.Request.Files[fileName];
                        if (file == null || file.ContentLength == 0)
                            continue;
                        //remove existing resource
                        var resourceParts = fileName.Split('_');
                        if (resourceParts.Length > 1)
                        {
                            int resourceId = int.Parse(resourceParts[1]);
                            _resourceSer.Del(resourceId);
                        }

                    }
                    //add new resource
                    _resourceSer.Save(ControllerContext.HttpContext.Request.Files
                          , CurrentUser.CustomerId
                        , -1, entity.Id
                        , SourceType.BannerPromotion);
                }
                ts.Complete();
            }
            return RedirectToAction("Details", new { id=entity.Id});
        }
        public ActionResult Create(FormCollection formCollection, BannerViewModel vo)
        {
            if (ModelState.IsValid)
            {
                var entity = new BannerEntity();
                entity.CreatedUser = base.CurrentUser.CustomerId;
                entity.UpdatedUser = base.CurrentUser.CustomerId;
                entity.CreatedDate = DateTime.Now;
                entity.UpdatedDate = DateTime.Now;
                entity.SourceId = vo.SourceId;
                entity.SourceType = (int)SourceType.Promotion;
                entity.SortOrder = vo.SortOrder;
                
                entity.Status = (int)DataStatus.Default;
                
                using (TransactionScope ts = new TransactionScope())
                {

                    entity = this._bannerRepo.Insert(entity);
                    var ids = _resourceSer.Save(ControllerContext.HttpContext.Request.Files
                        , CurrentUser.CustomerId
                        , -1, entity.Id
                        , SourceType.BannerPromotion);
                    ts.Complete();
                }

                return RedirectToAction("Edit", new {id=entity.Id });
            }

            return View(vo);
        }