public SubjectsResponse GetAllSubjects(SubjectRequest request)
        {
            SubjectsResponse response = new SubjectsResponse
            {
                Subjects =
                    _repository.GetAll()
                    .Where(x => x.IsActive == 1)
                    .Select(b => new BookCategoryView
                {
                    Id = b.Id,
                    CategoryNameBengali = b.NameB,
                    CategoryNameEnglish = b.NameE
                })
            };


            var bookCategoryViews = response.Subjects as BookCategoryView[] ?? response.Subjects.ToArray();

            response.Initials =
                bookCategoryViews.Select(summary => summary.CategoryNameBengali.ToArray()[0].ToString()).ToList();

            response.CategoryCount = bookCategoryViews.Count();

            if (!string.IsNullOrEmpty(request.SearchString))
            {
                bookCategoryViews = bookCategoryViews.Where(x => x.CategoryNameBengali.StartsWith(request.SearchString)).ToArray();
            }

            response.Subjects = bookCategoryViews.Skip(request.Skip).Take(request.Take);


            return(response);
        }
Ejemplo n.º 2
0
        public async Task <SubjectsResponse> GetSubjectsAsync()
        {
            string requestUri = string.Format(SUBJECTS_URL, authResponse.UserID);

            HttpContent httpContent = await SendRequestAsync(HttpMethod.Get, requestUri, null);

            SubjectsResponse response = JsonConvert.DeserializeObject <SubjectsResponse>(await httpContent.ReadAsStringAsync());

            AccountDetails.Subjects.Clear();
            AccountDetails.Subjects.AddRange(response.Subjects);

            return(response);
        }