protected void ExtraModelToEntity(User entity, UserModel model, ActionTypes actionType) { if (actionType == ActionTypes.Add) { entity.Password = StringHelper.GetMD5Hash(model.password); entity.Key = StringHelper.GetMD5Hash(String.Format("{0}_{1}", model.login, model.password)); } }
protected override void Validate(UserModel model, User entity, ActionTypes actionType) { if (!string.Equals(model.login, entity.Login, System.StringComparison.InvariantCultureIgnoreCase)) { if (Manager.GetByLogin(model.login) != null) ModelState.AddModelError("model.login", "login-unique"); } if (actionType == ActionTypes.Add) { if (string.IsNullOrEmpty(model.password)) ModelState.AddModelError("model.password", "required"); } }