public TaskResult<IEnumerable<StoryDetail>> GetStoriesForGroupByRequest(int groupId, DataRequest request)
        {
            TaskResult < IEnumerable < StoryDetail >> result = null;
               try
               {
               result = new TaskResult<IEnumerable<StoryDetail>> { state = StatusState.DoneState };

               IEnumerable<Story>  stories= _storyRepository.GetStoriesForGroup((int)groupId, request);
               result.Data = stories.Select(a => new StoryDetail { Content = a.Content, Description = a.Description, GroupDetails = a.Groups.Select(g => new GroupDetail { Description=g.Description,Id=g.Id,Name=g.Name}), Id = a.Id, PostedOn = a.DateCreated.Value, Title = a.Title, UserId = a.UserId }).AsEnumerable<StoryDetail>();
               }
               catch(Exception e)
               {
               Logger.Instance.LogException(e);
               result = new TaskResult<IEnumerable<StoryDetail>> { Data = null, state = StatusState.CancelState };
               }
               return result;
        }
        public TaskResult<IEnumerable<GroupDetail>> GetGroupsWithDetail(DataRequest request)
        {
            TaskResult<IEnumerable<GroupDetail>> result = null;
            try
            {

                result = new TaskResult<IEnumerable<GroupDetail>> { state = StatusState.DoneState };
                IEnumerable<GroupDetail> groups = _groupRepository.GetGroupsWithDetailsByRequest(request);
                result.Data = groups;
            }
            catch (Exception e)
            {
                Logger.Instance.LogException(e);
                result = new TaskResult<IEnumerable<GroupDetail>> { Data = null, state = StatusState.CancelState };
            }
            return result;
        }
        public TaskResult<IEnumerable<GroupDetail>> GetGroupsWithDetails(DataRequest request)
        {
            TaskResult<IEnumerable<GroupDetail>> result = null;
            HttpClient client = GetHTTPClient();
            var content = new ObjectContent(typeof(DataRequest), request, new JsonMediaTypeFormatter());
            HttpResponseMessage response = client.PostAsync("api/Group/GetGroupsWithDetails", content).Result;

            if (response.IsSuccessStatusCode)
            {
                result = response.Content.ReadAsAsync<TaskResult<IEnumerable<GroupDetail>>>().Result;

            }
            else
            {
                result = new TaskResult<IEnumerable<GroupDetail>> { state = StatusState.CancelState, Data = null };
            }
            return result;
        }
        public TaskResult<IEnumerable<GroupDetail>> GetGroupsByRequest(DataRequest request)
        {
            TaskResult<IEnumerable<GroupDetail>> result = null;
            try
            {
                result = new TaskResult<IEnumerable<GroupDetail>> { state = StatusState.DoneState };

                IEnumerable<Group> groups = _groupRepository.GetGroupsByRequest(request);

                result.Data = groups.Select(a => new GroupDetail { Description = a.Description, Id = a.Id, Name = a.Name }).AsEnumerable<GroupDetail>();
            }
            catch (Exception e)
            {
                Logger.Instance.LogException(e);
                result = new TaskResult<IEnumerable<GroupDetail>> { Data = null, state = StatusState.CancelState };
            }
            return result;
        }
        public TaskResult<ICollection<StoryDetail>> GetStoriesByUser(int UserId, DataRequest request)
        {
            TaskResult<ICollection<StoryDetail>> result = null;
            HttpClient client = GetHTTPClient();
            var wrappedRequest = new RequestWrapper { Id = UserId, request = request };
            var content = new ObjectContent(typeof(RequestWrapper), wrappedRequest, new JsonMediaTypeFormatter());
            HttpResponseMessage response = client.PostAsync("api/Story/GetStoriesByUser", content).Result;

            if (response.IsSuccessStatusCode)
            {
                result = response.Content.ReadAsAsync<TaskResult<ICollection<StoryDetail>>>().Result;

            }
            else
            {
                result = new TaskResult<ICollection<StoryDetail>> { state = StatusState.CancelState, Data = null };
            }
            return result;
        }