Exemplo n.º 1
0
        public IActionResult DeleteItemFromBook(string BookDetailID)
        {
            List <Guid> BookIDs = new List <Guid>();

            BookIDs.Add(Guid.Parse(BookDetailID));
            DeleteItemBookOutputModel OutPutData = new DeleteItemBookOutputModel();
            DeleteItemBookInputModel  filter     = new DeleteItemBookInputModel();

            filter.UserID = Guid.Parse(HttpContext.Session.GetString(SessionKeyID));
            filter.BookID = BookIDs;
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(BaseAPI + "Site/");
                var responseTask = client.PostAsJsonAsync <DeleteItemBookInputModel>("DeleteItemFromBooked", filter);
                responseTask.Wait();

                var result = responseTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    var content = result.Content.ReadAsStringAsync();
                    DeleteItemBookResponseModel resutl = Newtonsoft.Json.JsonConvert.DeserializeObject <DeleteItemBookResponseModel>(content.Result);
                    OutPutData = resutl.data;
                    return(RedirectToAction("BookDetail", "Booking", new { @id = BookDetailID }));
                }
                else                 //web api sent error response
                {
                    //log response status here..
                    ModelState.AddModelError(string.Empty, "Server error. Please contact administrator.");
                }
            }
            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 2
0
        public ActionResult <DeleteItemBookResponseModel> DeleteItemFromBooked([FromBody] DeleteItemBookInputModel data)
        {
            DeleteItemBookResponseModel res = new DeleteItemBookResponseModel();

            try
            {
                BookBL bl    = new BookBL(DbContext);
                var    respo = bl.DeleteItem(data);

                res.Message  = respo.Message;
                res.Response = true;

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

                return(res);
            }
        }