public RestAPISearchUserResponse SearchUser([FromUri] string SearchName)
        {
            RestAPISearchUserResponse response = new RestAPISearchUserResponse();

            usersUtils.SearchUser(response, SearchName);

            return(response);
        }
Example #2
0
        public void SearchUser(RestAPISearchUserResponse response, string SearchName)
        {
            List <RESTAPIUserInterchange> userInterchangeList = null;
            List <User> userlist = null;


            DatabaseWrapper.databaseOperation(response,
                                              (context, query) =>
            {
                userInterchangeList = new List <RESTAPIUserInterchange>();
                userlist            = new List <User>();

                if (!String.IsNullOrEmpty(SearchName))
                {
                    userlist = query.GetUsers(context, SearchName);
                    if (userlist.Count > 0)
                    {
                        foreach (var user in userlist)
                        {
                            RESTAPIUserInterchange userInterchange = new RESTAPIUserInterchange(user);
                            userInterchangeList.Add(userInterchange);
                        }
                        response.Status = Enum.GetName(typeof(ResponseStatusType), ResponseStatusType.Success);
                    }
                    else
                    {
                        response.Status = Enum.GetName(typeof(ResponseStatusType), ResponseStatusType.Failure);
                        response.ErrorList.Add(Faults.UserNotFound);
                        return;
                    }
                }
                else
                {
                    response.ErrorList.Add(Faults.InvalidSearch);
                    return;
                }
            }
                                              , readOnly: true
                                              );

            if (userInterchangeList != null && userInterchangeList.Count > 0)
            {
                response.UserSearchList.AddRange(userInterchangeList);
            }
        }