Esempio n. 1
0
        public IActionResult DeleteFromWishList(string ID)
        {
            DeleteFromWishListOutputModel OutPutData = new DeleteFromWishListOutputModel();
            DeleteFromWishListInputModel  filter     = new DeleteFromWishListInputModel();

            filter.WishListID = Guid.Parse(ID);
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(BaseAPI + "Site/");
                var responseTask = client.PostAsJsonAsync <DeleteFromWishListInputModel>("DeleteFromWishList", filter);
                responseTask.Wait();

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

            try
            {
                WishListBL bl   = new WishListBL(DbContext);
                var        temp = bl.DeleteFromWishList(data.WishListID);

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

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

                return(res);
            }
        }