Exemplo n.º 1
0
        public ActionResult Edit(FormCollection formCollection, [FetchPromotion(KeyName = "id")]PromotionEntity entity, PromotionViewModel vo)
        {
            if (entity == null || !ModelState.IsValid)
            {
                ModelState.AddModelError("", "参数验证失败.");
                return View(vo);
            }


            entity.UpdatedDate = DateTime.Now;
            entity.UpdatedUser = base.CurrentUser.CustomerId;
            entity.Store_Id = vo.Store_Id;
            entity.Status = vo.Status;
            entity.IsProdBindable = vo.IsProdBindable;
            entity.IsTop = vo.IsTop;
            entity.Name = vo.Name;
            entity.PublicationLimit = vo.PublicationLimit;
            entity.StartDate = vo.StartDate;
            entity.EndDate = vo.EndDate;
            entity.Description = vo.Description;
            entity.IsMain = vo.IsMain;
            entity.IsLimitPerUser = vo.IsLimitPerUser;
            entity.PublicProCode = vo.PublicProCode;
            using (TransactionScope ts = new TransactionScope())
            {
                this._promotionRepository.Update(entity);
                if (ControllerContext.HttpContext.Request.Files.Count > 0)
                {
                    this._resourceService.Save(ControllerContext.HttpContext.Request.Files
                          , CurrentUser.CustomerId
                        , -1, entity.Id
                        , SourceType.Promotion);
                }
                ts.Complete();
            }
            return RedirectToAction("List");
        }
Exemplo n.º 2
0
        public ActionResult Create(FormCollection formCollection, PromotionViewModel vo)
        {
            if (ModelState.IsValid)
            {
                var entity = MappingManager.PromotionEntityMapping(vo);
                entity.CreatedUser = base.CurrentUser.CustomerId;
                entity.UpdatedUser = base.CurrentUser.CustomerId;
                entity.RecommendSourceId = CurrentUser.CustomerId;
                entity.RecommendSourceType = (int)RecommendSourceType.Default;
                entity.RecommendUser = CurrentUser.CustomerId;
                entity.Status = (int)DataStatus.Default;
                entity.IsMain = true;
                using (TransactionScope ts = new TransactionScope())
                {

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

                return RedirectToAction("List");
            }

            return View(vo);
        }