当前位置: 首页>>代码示例>>C#>>正文


C# User.IsValid方法代码示例

本文整理汇总了C#中User.IsValid方法的典型用法代码示例。如果您正苦于以下问题:C# User.IsValid方法的具体用法?C# User.IsValid怎么用?C# User.IsValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在User的用法示例。


在下文中一共展示了User.IsValid方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Save

 public void Save(User user)
 {
     if (user.IsValid())
     {
         UserRepo.Save(user);
     }
 }
开发者ID:mkhj,项目名称:EcoHotels,代码行数:7,代码来源:UserService.cs

示例2: IsValid

		public void IsValid()
		{
			ActiveRecordStarter.Initialize( GetConfigSource(), typeof(User) );

			User user = new User();

			Assert.IsFalse(user.IsValid()); 

			user.Name = "hammett";
			user.Login = "hammett";
			user.Password = "123";
			user.ConfirmationPassword = "123";
			user.Email = "[email protected]";

			Assert.IsTrue(user.IsValid()); 
		}
开发者ID:sheefa,项目名称:Castle.ActiveRecord,代码行数:16,代码来源:ValidationTestCase.Generic.cs

示例3: IsValid

 public static bool IsValid(this Tenant tenant, User user)
 {
     return user.IsValid() &&
     AssertionConcern.IsSatisfiedBy
     (
         AssertionConcern.AssertNotNull(tenant.Id, "TenentId is required."),
         AssertionConcern.AssertNotEmpty(tenant.Name, "The tenant name is required."),
         AssertionConcern.AssertLength(tenant.Name, 1, 100, "The name must be 100 characters or less.")
     );
 }
开发者ID:rafaeltomitao,项目名称:collhub,代码行数:10,代码来源:TenantScope.cs

示例4: InsertInvalidInfo

        public static void InsertInvalidInfo()
        {
            log.Info("Insertando informacion invalida");
            User user = new User();
            //user.Username = "mario.chavez";
            user.Email = "[email protected]";

            if(!user.IsValid()) {
                foreach (var error in user.ValidationErrorMessages) {
                    log.Error(String.Format("Error: {0}", error));
                }
            }
        }
开发者ID:mariochavez,项目名称:Cesun-AppDistribuidas,代码行数:13,代码来源:Main.cs

示例5: Save

        public ActionResult Save(User model)
        {
            ExcludePropertiesInValidation("Profile.Name", "Profile.Functionalities");

            if (model.IsValid(ModelState))
            {
                model.Password = Models.User.EncriptPassword(model.Password);

                if (model.Id.Equals(0))
                {
                    Models.User.Create(model);
                }
                else
                {
                    Models.User.Update(model);
                }

                return new JsonResult ();
            }

            return View(ResultStatus.Attention);
        }
开发者ID:randomjs,项目名称:thunder,代码行数:22,代码来源:UsersController.cs

示例6: ErrorMessages

		public void ErrorMessages()
		{
			Thread.CurrentThread.CurrentCulture =
				Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us");

			ActiveRecordStarter.Initialize(GetConfigSource(), typeof(User));

			User user = new User();
			Type type = user.GetType();
			PropertyInfo info;
			ArrayList propertyMessages;

			Assert.IsFalse(user.IsValid());
			Assert.AreEqual(5, user.ValidationErrorMessages.Length);
			Assert.AreEqual("This is a required field", user.ValidationErrorMessages[0]);
			Assert.AreEqual("This is a required field", user.ValidationErrorMessages[1]);
			Assert.AreEqual("This is a required field", user.ValidationErrorMessages[2]);
			Assert.AreEqual("This is a required field", user.ValidationErrorMessages[3]);
			Assert.AreEqual("This is a required field", user.ValidationErrorMessages[4]);

			Assert.AreEqual(5, user.PropertiesValidationErrorMessages.Count);

			info = type.GetProperty("Login");
			Assert.IsTrue(user.PropertiesValidationErrorMessages.Contains(info));
			propertyMessages = (ArrayList)user.PropertiesValidationErrorMessages[info];
			Assert.AreEqual(1, propertyMessages.Count);
			Assert.AreEqual("This is a required field", propertyMessages[0]);

			info = type.GetProperty("Name");
			Assert.IsTrue(user.PropertiesValidationErrorMessages.Contains(info));
			propertyMessages = (ArrayList)user.PropertiesValidationErrorMessages[info];
			Assert.AreEqual(1, propertyMessages.Count);
			Assert.AreEqual("This is a required field", propertyMessages[0]);

			info = type.GetProperty("Email");
			Assert.IsTrue(user.PropertiesValidationErrorMessages.Contains(info));
			propertyMessages = (ArrayList)user.PropertiesValidationErrorMessages[info];
			Assert.AreEqual(1, propertyMessages.Count);
			Assert.AreEqual("This is a required field", propertyMessages[0]);

			info = type.GetProperty("Password");
			Assert.IsTrue(user.PropertiesValidationErrorMessages.Contains(info));
			propertyMessages = (ArrayList)user.PropertiesValidationErrorMessages[info];
			Assert.AreEqual(1, propertyMessages.Count);
			Assert.AreEqual("This is a required field", propertyMessages[0]);

			info = type.GetProperty("ConfirmationPassword");
			Assert.IsTrue(user.PropertiesValidationErrorMessages.Contains(info));
			propertyMessages = (ArrayList)user.PropertiesValidationErrorMessages[info];
			Assert.AreEqual(1, propertyMessages.Count);
			Assert.AreEqual("This is a required field", propertyMessages[0]);

			user.Name = "hammett";
			user.Login = "hammett";
			user.Email = "[email protected]";
			user.Password = "123x";
			user.ConfirmationPassword = "123";

			Assert.IsFalse(user.IsValid());
			Assert.AreEqual(1, user.ValidationErrorMessages.Length);
			Assert.AreEqual("Fields do not match", user.ValidationErrorMessages[0]);

			info = type.GetProperty("Password");
			Assert.IsTrue(user.PropertiesValidationErrorMessages.Contains(info));
			propertyMessages = (ArrayList)user.PropertiesValidationErrorMessages[info];
			Assert.AreEqual(1, propertyMessages.Count);
			Assert.AreEqual("Fields do not match", propertyMessages[0]);

			user.Password = "123";

			Assert.IsTrue(user.IsValid());
			Assert.AreEqual(0, user.ValidationErrorMessages.Length);
		}
开发者ID:sheefa,项目名称:Castle.ActiveRecord,代码行数:73,代码来源:ValidationTestCase.Generic.cs

示例7: Add

 /// <summary>
 /// Add user to repository
 /// </summary>
 /// <param name="user"></param>
 public int Add(User user)
 {
     rwls.EnterWriteLock();
     try
     {
         ts.TraceInformation($"Add user request in MasterService at {DateTime.Now} in {AppDomain.CurrentDomain.FriendlyName}");
         if (ReferenceEquals(null, user))
         {
             ts.TraceInformation($"Argument null exception in add user request at master in {AppDomain.CurrentDomain.FriendlyName}");
             throw new ArgumentNullException();
         }
         if (!user.IsValid())
         {
             ts.TraceInformation($"Validation exception in add user request at master in {AppDomain.CurrentDomain.FriendlyName}");
             throw new ArgumentException("Validation error : Incorrect user entity");
         }
         _id = StorageType.Add(user);
         OnModify(new Message("UserAdded", _id, user, null));
         return _id;
     }
     finally
     {
         rwls.ExitWriteLock();
     }
 }
开发者ID:RomanMakarov1002,项目名称:EPAM.RD.2016S.Makarau,代码行数:29,代码来源:MasterUserService.cs


注:本文中的User.IsValid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。