コード例 #1
0
ファイル: UserBusiness.cs プロジェクト: ozgend/cronom-blog
        public User SearchUser(Search search)
        {
            User user = null;

            if (search.Id > 0)
            {
                user = Util.Users.SingleOrDefault(u => u.Id == search.Id);
            }
            else if (!string.IsNullOrEmpty(search.Email))
            {
                user = Util.Users.SingleOrDefault(u => u.Email == search.Email);
            }
            else if (!string.IsNullOrEmpty(search.Name))
            {
                user = Util.Users.SingleOrDefault(u => u.Name == search.Name);
            }
            else {
                throw new Exception("No search parameter specified.");
            }

            if (user != null)
            {
                return user;
            }
            else
            {
                throw new Exception("Search yields no result.");
            }
        }
コード例 #2
0
 public object Search(Search search)
 {
     try
     {
         User user = _userBusiness.SearchUser(search);
         return new { Ok = true, User = user };
     }
     catch (Exception ex)
     {
         return new { Ok = false, Message = ex.Message };
     }
 }