示例#1
0
        public ActionResult Update(FormCollection formCollection, [FetchBrand(KeyName = "brandid")]BrandEntity Brand, BrandCreateViewModel vo)
        {
            if (this.ModelState.IsValid)
            {
                Brand = Mapper.Map(vo, Brand);
                Brand.UpdatedDate = DateTime.Now;
                Brand.UpdatedUser = base.CurrentUser.CustomerId;

                this._repository.Update(Brand);

                return View("Success", new SuccessViewModel
                    {
                        BackName = "主页",
                        BackUrl = Url.Action("Index", "Home"),
                        MessageDesc = "编辑品牌:" + Brand.Name + " 成功",
                        MessageTitle = "编辑品牌成功",
                        Title = "编辑品牌成功"
                    });
            }
            else
            {
                ModelState.AddModelError("", "参数验证错误.");
                Brand.Name = vo.Name;
            }

            return View(Brand);
        }
示例#2
0
        public ActionResult Create(FormCollection formCollection, BrandCreateViewModel vo)
        {
            if (this.ModelState.IsValid)
            {
                var entity = new BrandEntity{
                        Name = vo.Name,
                        EnglishName = String.Empty,
                        Description = String.Empty,
                        Logo = String.Empty,
                        Group = String.Empty,
                        WebSite = String.Empty,
                        CreatedDate = DateTime.Now,
                        CreatedUser = base.CurrentUser.CustomerId,
                        UpdatedDate = DateTime.Now,
                        Status = (int)DataStatus.Normal,
                        UpdatedUser = 0
                    };
                var entityNew = this._repository.Insert(entity);

                return View("Success", new SuccessViewModel
                    {
                        BackName = "主页",
                        BackUrl = Url.Action("Index", "Home"),
                        MessageDesc = "创建品牌:" + entityNew.Name + " 成功",
                        MessageTitle = "创建品牌成功",
                        Title = "创建品牌成功"
                    });
            }
            else
            {
                ModelState.AddModelError("", "参数验证错误.");
            }

            return View(vo);
        }