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);
        }
Ejemplo n.º 3
0
        public ActionResult Index(SortTimeZone sort, SortOrder order, int? page)
        {
            var timeZones = this.TimeZoneService.GetPaged(new TimeZoneSpecification
            {
                Page = page,
                Limit = Setting.TimeZonePageLimit.Value,
                Sort = sort,
                Order = order
            });

            var timeZone = timeZones.FirstOrDefault();
            var privilege = new TimeZonePrivilege();

            return privilege.CanView(timeZone) ? base.View(Views.Index, timeZones) : NotAuthorized();
        }
Ejemplo n.º 4
0
        public ActionResult Update(int id)
        {
            var timeZone = this.TimeZoneService.GetById(id);

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

            var privilege = new TimeZonePrivilege();

            return privilege.CanUpdate(timeZone) ? base.View(Views.Update, new TimeZoneCreateOrUpdate(timeZone)) : NotAuthorized();
        }
Ejemplo n.º 5
0
        public ActionResult Delete(TimeZoneDelete value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            var timeZone = this.TimeZoneService.GetById(value.Id);

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

            var privilege = new TimeZonePrivilege();

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

            this.TimeZoneService.Delete(timeZone);

            return base.RedirectToRoute(AdministrationRoutes.TimeZoneIndex);
        }