public void Test_UserHostSearchDelete()
        {
            var value = new UserHostSearchDelete(
                new UserHostSearch
                {
                    Id = 1,
                    Title = "test"
                }
            );

            Assert.AreEqual(1, value.Id, "Id");
            Assert.AreEqual("test", value.Title, "Title");
        }
        public void Test_HostSearchController_Delete_Post()
        {
            PrincipalHelper.Create();

            var value = new UserHostSearchDelete
            {
                Id = 1
            };

            var redirectToRouteResult = this.HostSearchController.Delete(value) as RedirectToRouteResult;

            Assert.IsNotNull(redirectToRouteResult, "RedirectToRouteResult");
            Assert.AreEqual(UsersAdministrationRoutes.HostSearchCreate, redirectToRouteResult.RouteName);

            PrincipalHelper.Clear();

            var notAuthorizedResult = this.HostSearchController.Delete(value) as NotAuthorizedResult;

            Assert.IsNotNull(notAuthorizedResult, "NotAuthorizedResult");
        }
        public ActionResult Delete(UserHostSearchDelete value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            var search = UserHostSearchService.GetById(value.Id);

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

            var privilege = new UserHostSearchPrivilege();

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

            this.UserHostSearchService.Delete(search);

            return base.RedirectToRoute(UsersAdministrationRoutes.HostSearchCreate);
        }