예제 #1
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);
        }