|
@@ -75,7 +75,7 @@ namespace WebPortal.Controllers
|
|
|
SetWsClient(ref wsClient);
|
|
SetWsClient(ref wsClient);
|
|
|
if (keywords != null && keywords.Trim().Length >= 2)
|
|
if (keywords != null && keywords.Trim().Length >= 2)
|
|
|
{
|
|
{
|
|
|
- // search content
|
|
|
|
|
|
|
+ // search content (except news)
|
|
|
wsSearchTreeContentRequest wsRequest = new wsSearchTreeContentRequest(
|
|
wsSearchTreeContentRequest wsRequest = new wsSearchTreeContentRequest(
|
|
|
BaseController.wsUser,
|
|
BaseController.wsUser,
|
|
|
BaseController.wsPassword,
|
|
BaseController.wsPassword,
|
|
@@ -131,6 +131,53 @@ namespace WebPortal.Controllers
|
|
|
listTemp.Clear();
|
|
listTemp.Clear();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // load news
|
|
|
|
|
+ wsRequest = new wsSearchTreeContentRequest(
|
|
|
|
|
+ BaseController.wsUser,
|
|
|
|
|
+ BaseController.wsPassword,
|
|
|
|
|
+ ProductType.NEWS,
|
|
|
|
|
+ keywords,
|
|
|
|
|
+ getCurrentLang());
|
|
|
|
|
+ wsResponse = wsClient.wsSearchTreeContent(wsRequest);
|
|
|
|
|
+ listContent = wsResponse.@return.listContent;
|
|
|
|
|
+ if (listContent != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ // add new group
|
|
|
|
|
+ wsGetTreeByCodeRequest reqParent = new wsGetTreeByCodeRequest();
|
|
|
|
|
+ reqParent.nodeCode = ProductType.NEWS;// wsUser, wsPassword, , getCurrentLang()
|
|
|
|
|
+ reqParent.WsUser = wsUser;
|
|
|
|
|
+ reqParent.WsPass = wsPassword;
|
|
|
|
|
+ reqParent.lang = getCurrentLang();
|
|
|
|
|
+ var group = wsClient.wsGetTreeByCode(reqParent).@return.listContent[0];
|
|
|
|
|
+ groupModel = new ProductModel();
|
|
|
|
|
+ groupModel.content = group;
|
|
|
|
|
+ groupModel.listContent = listContent;
|
|
|
|
|
+ // calculate page
|
|
|
|
|
+ int totalPage = (int)Math.Ceiling(listContent.Length / 6m);
|
|
|
|
|
+ int currentPage = 1;
|
|
|
|
|
+ if (totalPage > 1)
|
|
|
|
|
+ {
|
|
|
|
|
+ groupModel.nextPage = currentPage + 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ // store session
|
|
|
|
|
+ HttpContext.Session.SetComplexData("newsModel", groupModel);
|
|
|
|
|
+
|
|
|
|
|
+ // get max 6 news
|
|
|
|
|
+ var groupNews = new ProductModel();
|
|
|
|
|
+ groupNews.content = group;
|
|
|
|
|
+ groupNews.nextPage = groupModel.nextPage;
|
|
|
|
|
+ List<contentTreeObj> listNews = new List<contentTreeObj>();
|
|
|
|
|
+ for (int i = 0; i< 6; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (i < listContent.Length)
|
|
|
|
|
+ {
|
|
|
|
|
+ listNews.Add(listContent[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ groupNews.listContent = listNews.ToArray();
|
|
|
|
|
+ listGroup.Add(groupNews);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
ViewBag.keywords = keywords;
|
|
ViewBag.keywords = keywords;
|
|
|
return View(listGroup);
|
|
return View(listGroup);
|
|
|
}
|
|
}
|
|
@@ -147,6 +194,60 @@ namespace WebPortal.Controllers
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ [HttpPost]
|
|
|
|
|
+ //[ValidateAntiForgeryToken]
|
|
|
|
|
+ public IActionResult NewsLoad()
|
|
|
|
|
+ {
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ ProductModel groupModel = HttpContext.Session.GetComplexData<ProductModel>("newsModel");
|
|
|
|
|
+ int currentPage = groupModel.nextPage;
|
|
|
|
|
+ int totalPage = (int)Math.Ceiling(groupModel.listContent.Length / 6m);
|
|
|
|
|
+ if (totalPage > currentPage)
|
|
|
|
|
+ {
|
|
|
|
|
+ groupModel.nextPage = currentPage + 1;
|
|
|
|
|
+ } else
|
|
|
|
|
+ {
|
|
|
|
|
+ groupModel.nextPage = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ HttpContext.Session.SetComplexData("newsModel", groupModel);
|
|
|
|
|
+
|
|
|
|
|
+ // load next news
|
|
|
|
|
+ var groupNews = new ProductModel();
|
|
|
|
|
+ groupNews.content = groupModel.content;
|
|
|
|
|
+ groupNews.nextPage = groupModel.nextPage;
|
|
|
|
|
+ List<contentTreeObj> listNews = new List<contentTreeObj>();
|
|
|
|
|
+ for (int i = currentPage * 6; i < currentPage * 6 + 6; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (i < groupModel.listContent.Length)
|
|
|
|
|
+ {
|
|
|
|
|
+ listNews.Add(groupModel.listContent[i]);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ groupNews.listContent = listNews.ToArray();
|
|
|
|
|
+
|
|
|
|
|
+ //model.listContent = listNews;
|
|
|
|
|
+ //var totalPage = wsResponse.@return.totalPage;
|
|
|
|
|
+ //int nextPage = int.Parse(page) + 1;
|
|
|
|
|
+ //if (totalPage >= nextPage)
|
|
|
|
|
+ //{
|
|
|
|
|
+ // model.nextPage = nextPage;
|
|
|
|
|
+ //}
|
|
|
|
|
+
|
|
|
|
|
+ return PartialView("../Home/_News", groupNews);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception ex)
|
|
|
|
|
+ {
|
|
|
|
|
+ log.Error("Exception NewsLoad", ex);
|
|
|
|
|
+ return Json(new
|
|
|
|
|
+ {
|
|
|
|
|
+ error_code = "-1",
|
|
|
|
|
+ error_content = "System failed"
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public ActionResult FaqDetail(String id)
|
|
public ActionResult FaqDetail(String id)
|
|
|
{
|
|
{
|
|
|
// load FAQs
|
|
// load FAQs
|