Ejemplo n.º 1
0
        public async Task <JsonResult> get_promotion()
        {
            long    lTime    = new DateTimeOffset(Convert.ToDateTime(DateTime.Now)).ToUniversalTime().ToUnixTimeSeconds();
            VMError objError = new VMError();

            var helper   = new InfoNewsHelper();
            var dataItem = await helper.GetNews("chuong_trinh_khuyen_mai");

            if (dataItem != null)
            {
                return(await Task.Run(() => Json(new { result = 1, time = lTime, data = dataItem, error = objError })));
            }

            objError.code    = 201;
            objError.message = "Dữ liệu không hợp lệ";
            return(await Task.Run(() => Json(new { result = 0, time = lTime, data = dataItem, error = objError })));
        }
Ejemplo n.º 2
0
        public async Task <JsonResult> get_news(int size, int page_number)
        {
            long    lTime    = new DateTimeOffset(Convert.ToDateTime(DateTime.Now)).ToUniversalTime().ToUnixTimeSeconds();
            VMError objError = new VMError();

            var helper   = new InfoNewsHelper();
            var dataItem = await helper.GetNews("tin_tuc", size, page_number);

            if (dataItem != null)
            {
                return(await Task.Run(() => Json(new { result = 1, time = lTime, data = dataItem, error = objError })));
            }

            objError.code    = 201;
            objError.message = "Dữ liệu không hợp lệ";
            return(await Task.Run(() => Json(new { result = 0, time = lTime, data = dataItem, error = objError })));
        }
Ejemplo n.º 3
0
        public async Task <JsonResult> get_info(string keyword, int records)
        {
            long    lTime    = new DateTimeOffset(Convert.ToDateTime(DateTime.Now)).ToUniversalTime().ToUnixTimeSeconds();
            VMError objError = new VMError();

            var helper = new InfoNewsHelper();
            var items  = await helper.GetNews(keyword, records);

            if (items != null && items.Any())
            {
                if (items != null)
                {
                    var dataItem = items.OrderByDescending(o => o.id).FirstOrDefault();
                    return(await Task.Run(() => Json(new { result = 1, time = lTime, data = dataItem, error = objError })));
                }
            }

            objError.code    = 201;
            objError.message = "Dữ liệu không hợp lệ";
            return(await Task.Run(() => Json(new { result = 0, time = lTime, data = new object(), error = objError })));
        }