Example #1
0
        public async Task <HttpResponseMessage> GetAllAsync()
        {
            var Res    = Request.CreateResponse();
            var Result = new Res();

            try
            {
                var data = await Task.Run(() => _advertisementService.GetAll());

                if (data != null)
                {
                    Result.Data       = data;
                    Result.Status     = true;
                    Result.Message    = "Call API Success";
                    Result.StatusCode = HttpStatusCode.OK;
                }
                else
                {
                    Result.Data       = null;
                    Result.Status     = false;
                    Result.Message    = "Không tìm thấy dữ liệu";
                    Result.StatusCode = HttpStatusCode.InternalServerError;
                }
                Res.Content = new StringContent(JsonConvert.SerializeObject(Result));
                return(Res);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Example #2
0
 public ActionResult Index()
 {
     ViewBag.quangcao = AdvertisementService.GetAll();
     return(View());
 }