public void Test_TimeZoneCreateOrUpdate_ValueToModel() { var value = new TimeZoneCreateOrUpdate { Title = "test", Display = "test2", Offset = 2 }; var country = new TimeZone(); value.ValueToModel(country); Assert.AreEqual("test", value.Title, "Title"); Assert.AreEqual("test2", value.Display, "Display"); Assert.AreEqual(2, value.Offset, "Offset"); }
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); }