Exemplo n.º 1
0
        public IActionResult SendNotifiExpired()
        {
            List <NotificationBookOutputModel> OutPutData = new List <NotificationBookOutputModel>();
            NotificationBookInputModel         filter     = new NotificationBookInputModel();

            filter.ExpiredDate = DateTime.Parse("");
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(BaseAPI + "Site/");
                var responseTask = client.PostAsJsonAsync <NotificationBookInputModel>("SendNotifiExpired", filter);
                responseTask.Wait();

                var result = responseTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    var content = result.Content.ReadAsStringAsync();
                    NotificationBookResponseModel resutl = Newtonsoft.Json.JsonConvert.DeserializeObject <NotificationBookResponseModel>(content.Result);
                    OutPutData = resutl.data;
                }
                else                 //web api sent error response
                {
                    //log response status here..
                    ModelState.AddModelError(string.Empty, "Terjadi kesalahan. Mohon hubungi admin.");
                }
            }
            return(Json(OutPutData));
        }
Exemplo n.º 2
0
        public ActionResult <NotificationBookResponseModel> SendNotifiExpired([FromBody] NotificationBookInputModel data)
        {
            NotificationBookResponseModel res = new NotificationBookResponseModel();

            try
            {
                BookBL bl   = new BookBL(DbContext);
                var    temp = bl.GetExpiredBook(data);
                res.data = temp;

                res.Message  = "Success";
                res.Response = true;

                return(res);
            }
            catch (Exception ex)
            {
                res.Message  = ex.Message;
                res.Response = false;

                return(res);
            }
        }