public void Test_UserBanCreateOrUpdate_Initialize()
        {
            var value = new UserBanCreateOrUpdate();

            value.Initialize(new User());

            Assert.IsNotNull(value.User, "User");
        }
예제 #2
0
        public ActionResult Update(UserBanCreateOrUpdate value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            var ban = this.UserBanService.GetById(value.Id);

            if (ban == null)
            {
                return base.HttpNotFound();
            }

            var privilege = new UserBanPrivilege();

            if (!privilege.CanUpdate(ban))
            {
                return NotAuthorized();
            }

            value.Validate();

            if (value.IsValid)
            {
                value.ValueToModel(ban);

                this.UserBanService.InsertOrUpdate(ban);

                value.SuccessMessage(Messages.UserBanUpdated.FormatInvariant(ban.User.Name));
            }
            else
            {
                value.CopyToModel(ModelState);
            }

            value.Initialize(ban.User);

            return base.View(Views.Update, value);
        }