Ejemplo n.º 1
0
        public void Test_UserHostSearchCreate_Initialize()
        {
            var value = new UserHostSearchCreate();

            value.Initialize(new List<UserHostSearch>());

            Assert.IsNotNull(value.Searches, "Searches");
        }
Ejemplo n.º 2
0
        public ActionResult Create()
        {
            var search = this.UserHostSearchService.Create();
            var privilege = new UserHostSearchPrivilege();

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

            var searches = this.UserHostSearchService.GetAll(new UserHostSearchUserSpecification(base.Identity.Id));
            var value = new UserHostSearchCreate();

            value.Initialize(searches);

            return base.View(Views.Create, value);
        }
Ejemplo n.º 3
0
        public ActionResult Create(UserHostSearchCreate value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            var search = this.UserHostSearchService.Create();
            var privilege = new UserHostSearchPrivilege();

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

            value.Validate();

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

                this.UserHostSearchService.Insert(search);

                return base.RedirectToRoute(UsersAdministrationRoutes.HostSearchIndex, new { id = search.Id });
            }

            value.CopyToModel(ModelState);

            var searches = this.UserHostSearchService.GetAll(new UserHostSearchUserSpecification(base.Identity.Id));

            value.Initialize(searches);

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