public UserListResponse Search(long id, SearchRequest req)
        {
            UserListResponse resp = new UserListResponse();

            try
            {
                if (ValidateRequest.SearchRequest(req))
                {
                    var userCrud = new UserCRUD();
                    if (userCrud.IsUserExists(id))
                    {
                        List <string> states            = req.Filters.Where(x => x.Filters == EFilters.States).Select(x => x.Values).FirstOrDefault();
                        List <string> homeType          = req.Filters.Where(x => x.Filters == EFilters.HomeType).Select(x => x.Values).FirstOrDefault();
                        List <string> homeZipCode       = req.Filters.Where(x => x.Filters == EFilters.HomeZipCode).Select(x => x.Values).FirstOrDefault();
                        List <string> numberOfKids      = req.Filters.Where(x => x.Filters == EFilters.NumberOfKids).Select(x => x.Values).FirstOrDefault();
                        int           minAge            = req.Filters.Where(x => x.Filters == EFilters.Age).Select(x => x.MinAge).FirstOrDefault();
                        int           maxAge            = req.Filters.Where(x => x.Filters == EFilters.Age).Select(x => x.MaxAge).FirstOrDefault();
                        bool          isAgeFilterExists = req.Filters.Any(x => x.Filters == EFilters.Age);

                        var userList = userCrud.GetUsers(states, homeType, homeZipCode, numberOfKids, isAgeFilterExists, minAge, maxAge);
                        if (userList.Count > 0)
                        {
                            resp.User = userList;
                            resp.OK();
                        }
                        else
                        {
                            resp.NotFound();
                        }
                    }
                    else
                    {
                        resp.Conflict();
                    }
                }
                else
                {
                    resp.BadRequest();
                }
            }
            catch (Exception es)
            {
                string reqData = JsonConvert.SerializeObject(req);
                logger.Error(string.Format("SearchRequest, UserID={0}, Req={1}", id, reqData));
                logger.Error("SearchRequest " + es.StackTrace);
                resp.InternalServerError();
            }
            return(resp);
        }
        public BaseResponse AddUser(UserRequest user)
        {
            BaseResponse resp = new BaseResponse();

            try
            {
                if (ValidateRequest.AddUser(user))
                {
                    var userCrud = new UserCRUD();

                    if (!userCrud.IsUserExists(user.User.PhoneNumber, user.User.Email) && !userCrud.IsUserExists(user.User.Id))
                    {
                        user.User.Id = 0;
                        new UserCRUD().AddUser(user.User);
                        if (user.User.Id > 0)
                        {
                            resp.OK();
                        }
                        else
                        {
                            resp.Conflict();
                        }
                    }
                    else
                    {
                        resp.Conflict();
                    }
                }
                else
                {
                    resp.BadRequest();
                }
            }
            catch (Exception es)
            {
                string req = JsonConvert.SerializeObject(user);
                logger.Error(string.Format("AddUser, Req={0}", req));
                logger.Error("AddUser " + es.StackTrace);
                resp.InternalServerError();
            }
            return(resp);
        }
        public BaseResponse InActivateUser(long id)
        {
            BaseResponse resp = new BaseResponse();

            try
            {
                if (ValidateRequest.InActivateUser(id))
                {
                    var userCrud = new UserCRUD();
                    if (userCrud.IsUserExists(id))
                    {
                        var status = userCrud.InActivateUser(id);
                        if (status > 0)
                        {
                            resp.OK();
                        }
                        else
                        {
                            resp.Conflict();
                        }
                    }
                    else
                    {
                        resp.Conflict();
                    }
                }
                else
                {
                    resp.BadRequest();
                }
            }
            catch (Exception es)
            {
                logger.Error(string.Format("DeleteUser, UserID={0}", id));
                logger.Error("DeleteUser " + es.StackTrace);
                resp.InternalServerError();
            }
            return(resp);
        }