public void Test_UserAdminCreate_Validate() { var value = new UserAdminCreate(); value.Validate(); Assert.AreEqual(6, value.Errors.Count, "Errors"); }
public ActionResult Create(UserAdminCreate value) { if (value == null) { throw new ArgumentNullException("value"); } var user = this.UserService.Create(); var privilege = new UserPrivilege(); if (!privilege.CanCreate(user)) { return NotAuthorized(); } value.Validate(); if (value.IsValid) { value.ValueToModel(user); this.UserService.Insert(user, value.Preference); var model = new UserAdminUpdate(user); model.SuccessMessage(Messages.UserCreated.FormatInvariant(user.Name)); return base.View(Views.Update, model); } value.CopyToModel(ModelState); return base.View(Views.Create, value); }