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


C# ServiceClient.GetUserByEmail方法代码示例

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


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

示例1: LogIn

        /// <summary>Attempts to log in as the User that identifies itself with the given email and password.</summary>
        /// <param name="email">The email that identifies the user.</param>
        /// <param name="password">The password that authorizes the user.</param>
        public static void LogIn(string email, string password)
        {
            if (_sessionUser != null)
                throw new NotLoggedOutException();

            using (var client = new ServiceClient())
            {
                var temp = client.GetUserByEmail(email);

                if (temp == null)
                    throw new NoSuchUserException();

                if (!temp.Password.Equals(password))
                    throw new IncorrectPasswordException();

                _sessionUser = temp;
            }
        }
开发者ID:Crelde,项目名称:ClientBNDN,代码行数:21,代码来源:Controller.cs

示例2: UserExists

 /// <summary>Used to check if there exists a User with a certain email.</summary>
 /// <param name="email">The email of the User in question.</param>
 /// <returns>True if there exists such a User, false if not.</returns>
 private static bool UserExists(string email)
 {
     using (var client = new ServiceClient())
     {
         try
         {
             return client.GetUserByEmail(email).Email.Equals(email);
         }
         catch (Exception)
         {
             return false;
         }
     }
 }
开发者ID:Crelde,项目名称:ClientBNDN,代码行数:17,代码来源:Controller.cs

示例3: GetUserByEmail

        /// <summary>Look up a User by its email address.</summary>
        /// <param name="email">The email of the User to be returned.</param>
        /// <returns>The User whose Email property matches the given email.</returns>
        public static User GetUserByEmail(string email)
        {
            if (_sessionUser == null)
                throw new NotLoggedInException();

            if (_sessionUser.Type != UserType.admin && !_sessionUser.Email.Equals(email))
                throw new InsufficientRightsException();

            if(!UserExists(email))
                throw new ObjectNotFoundException();

            using (var client = new ServiceClient())
            {
                return client.GetUserByEmail(email);
            }
        }
开发者ID:Crelde,项目名称:ClientBNDN,代码行数:19,代码来源:Controller.cs


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