コード例 #1
0
        public void Test_SettingDelete()
        {
            var value = new SettingDelete(
                new Setting
                {
                    Id = 1,
                    Title = "test"
                }
            );

            Assert.AreEqual(1, value.Id, "Id");
            Assert.AreEqual("test", value.Title, "Title");
        }
コード例 #2
0
        public ActionResult Delete(SettingDelete value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            var setting = this.SettingService.GetById(value.Id);

            if (setting == null)
            {
                return HttpNotFound();
            }

            var privilege = new SettingPrivilege();

            if (!privilege.CanDelete(setting))
            {
                return NotAuthorized();
            }

            this.SettingService.Delete(setting);

            return base.RedirectToRoute(AdministrationRoutes.SettingIndex);
        }