Example #1
0
        /// <summary>
        /// GetBlogs
        /// </summary>
        /// <param name="blogCategoryId"></param>
        /// <returns></returns>
        public ServiceResponse <BlogCategoryDC> GetBlogs(int blogCategoryId)
        {
            ServiceResponse <BlogCategoryDC> BlogsResponse = new ServiceResponse <BlogCategoryDC>();

            try
            {
                SetContext();
                BlogCategory BlogCategory = _contentManager.GetBlogs(blogCategoryId);
                BlogsResponse.Result       = Mapper.Map <BlogCategory, BlogCategoryDC>(BlogCategory);
                BlogsResponse.Result.Blogs = new List <BlogDC>();
                BlogCategory.Blogs.ToList().ForEach(result =>
                {
                    BlogsResponse.Result.Blogs.Add(Mapper.Map <Blog, BlogDC>(result));
                });
                ResponseContextParameter responseParameter = RequestContext.Current.Get <ResponseContextParameter>("ResponseParameter");
                BlogsResponse.ResponseParameters.NumberOfRecords = responseParameter.NumberOfRecords;
            }
            catch (Exception ex)
            {
                HandleError(ex, BlogsResponse);
            }
            return(BlogsResponse);
        }
Example #2
0
 public BaseClient()
 {
     this.RequestContext  = new RequestContextParameter();
     this.ResponseContext = new ResponseContextParameter();
 }
Example #3
0
 /// <summary>
 /// GetListResult
 /// </summary>
 /// <typeparam name="TDataObhject"></typeparam>
 /// <param name="dataObject"></param>
 /// <returns></returns>
 protected HttpResponseMessage GetListResult <TDataObhject>(TDataObhject dataObject, RequestContextParameter requestParameter, ResponseContextParameter responseParameter)
 {
     return(Request.CreateResponse(HttpStatusCode.OK, new ListModel <TDataObhject> {
         data = dataObject, recordsTotal = responseParameter.NumberOfRecords, recordsFiltered = responseParameter.NumberOfRecords, draw = requestParameter.Draw, length = requestParameter.PageSize, start = requestParameter.PageNumber
     }));
 }