Exemplo n.º 1
0
        public IHttpActionResult Post(ApiJsonDraw apiDraw, String level, String category, String keyword)
        {
            ApiJsonStatus apiJsonStatusM = Factory.Create <ApiJsonStatus>("ApiJsonStatus", ClassType.clsTypeDataModel);

            apiJsonStatusM.code    = 200;
            apiJsonStatusM.message = "Post ok " + apiDraw.draw;

            var start = 6 * (apiDraw.draw - 1);

            List <ArticleListJson> aljModel = new List <ArticleListJson>();

            var alModel = _articleBs.GetListApproved(start, level, category, keyword);

            foreach (var item in alModel)
            {
                ArticleListJson    ajModel  = Factory.Create <ArticleListJson>("ArticleListJson", ClassType.clsTypeDataModel);
                ArticleListJsonImg ajiModel = Factory.Create <ArticleListJsonImg>("ArticleListJsonImg", ClassType.clsTypeDataModel);

                string attachmentsPath = WebConfigure.GetDomain() + "/Upload/Article/Header/";
                ajiModel.src      = attachmentsPath + item.HeaderImage;
                ajiModel.label    = item.Category1;
                ajiModel.alt      = item.Category1;
                ajModel.img       = ajiModel;
                ajModel.link      = WebConfigure.GetDomain() + "/Library/Detail/" + item.ArticleId;
                ajModel.group_url = WebConfigure.GetDomain() + "/Library?category=" + item.Category1Id;
                ajModel.title     = item.Title;
                ajModel.text      = Common.GetShortDescription(item.Description);
                ajModel.type      = "Article";
                ajModel.date      = item.CreatedAt?.ToString("dd MMM yyyy");

                aljModel.Add(ajModel);
            }
            return(Ok(new { status = apiJsonStatusM, data = aljModel }));
        }
        public IHttpActionResult Post(string id, ApiJsonDraw apiDraw)
        {
            ApiJsonStatus apiJsonStatusM = Factory.Create <ApiJsonStatus>("ApiJsonStatus", ClassType.clsTypeDataModel);

            //var draw = Request.Content.ReadAsStringAsync();
            apiJsonStatusM.code    = 200;
            apiJsonStatusM.message = "Post ok " + apiDraw.draw;

            var start = 3 * (apiDraw.draw - 1);
            //if (start == 0)
            //    start = 1;

            List <ArticleListJson> aljModel = new List <ArticleListJson>();

            var alModel = _articleBs.GetListApprovedByCategory(start, id);

            foreach (var item in alModel)
            {
                ArticleListJson    ajModel  = Factory.Create <ArticleListJson>("ArticleListJson", ClassType.clsTypeDataModel);
                ArticleListJsonImg ajiModel = Factory.Create <ArticleListJsonImg>("ArticleListJsonImg", ClassType.clsTypeDataModel);

                string attachmentsPath = WebConfigure.GetDomain() + "/Upload/Article/Header/";
                ajiModel.src   = attachmentsPath + item.HeaderImage;
                ajiModel.label = item.Category1;
                ajiModel.alt   = item.Category1;
                ajModel.img    = ajiModel;
                ajModel.link   = WebConfigure.GetDomain() + "/Library/Detail/" + item.ArticleId;
                ajModel.title  = item.Title;
                ajModel.text   = Common.GetShortDescription(item.Description);
                ajModel.type   = "Artikel";
                ajModel.date   = item.CreatedAt?.ToString("dd MMM yyyy");

                aljModel.Add(ajModel);
            }

            return(Ok(new { status = apiJsonStatusM, data = aljModel }));
        }