Ejemplo n.º 1
0
        public ActionResult Create()
        {
            var timeZone = this.TimeZoneService.Create();
            var privilege = new TimeZonePrivilege();

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

            var timeZone = this.TimeZoneService.Create();
            var privilege = new TimeZonePrivilege();

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

            value.Validate();

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

                this.TimeZoneService.InsertOrUpdate(timeZone);

                value = new TimeZoneCreateOrUpdate(timeZone);
                value.SuccessMessage(Messages.TimeZoneCreated.FormatInvariant(timeZone.Title));
            }
            else
            {
                value.CopyToModel(ModelState);
            }

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