Esempio n. 1
0
        public ActionResult Create()
        {
            var country = this.CountryService.Create();
            var privilege = new CountryPrivilege();

            return privilege.CanCreate(country) ? base.View(Views.Create, new CountryCreateOrUpdate()) : NotAuthorized();
        }
Esempio n. 2
0
        public ActionResult Create(CountryCreateOrUpdate value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            var country = this.CountryService.Create();
            var privilege = new CountryPrivilege();

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

            value.Validate();

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

                this.CountryService.InsertOrUpdate(country);

                value = new CountryCreateOrUpdate(country);
                value.SuccessMessage(Messages.CountryCreated.FormatInvariant(country.Title));
            }
            else
            {
                value.CopyToModel(ModelState);
            }

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