Exemple #1
0
        public ActionResult Create(UserBanCreateOrUpdate value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            var ban = this.UserBanService.Create();
            var privilege = new UserBanPrivilege();

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

            value.Validate();

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

                this.UserBanService.InsertOrUpdate(ban, value.Name);

                value = new UserBanCreateOrUpdate(ban);
                value.SuccessMessage(Messages.UserBanCreated.FormatInvariant(ban.User.Name));
            }
            else
            {
                value.CopyToModel(ModelState);
            }

            return base.View(Views.Update, value);
        }
Exemple #2
0
        public ActionResult Update(int id)
        {
            var ban = this.UserBanService.GetById(id);

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

            var privilege = new UserBanPrivilege();

            return privilege.CanUpdate(ban) ? base.View(Views.Update, new UserBanCreateOrUpdate(ban)) : NotAuthorized();
        }