public void Test_TimeZoneCreateOrUpdate_Validate()
        {
            var value = new TimeZoneCreateOrUpdate();

            value.Validate();

            Assert.AreEqual(2, value.Errors.Count, "Errors");
        }
Esempio 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);
        }