Exemplo n.º 1
0
        public IActionResult AddToWishList(string site, string item)
        {
            AddToWishListOutputModel OutPutData = new AddToWishListOutputModel();
            AddToWishListInputModel  filter     = new AddToWishListInputModel();

            filter.UserID     = Guid.Parse(HttpContext.Session.GetString(SessionKeyID));
            filter.SiteID     = Guid.Parse(site);
            filter.SiteItemID = Guid.Parse(item);
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(BaseAPI + "Site/");
                var responseTask = client.PostAsJsonAsync <AddToWishListInputModel>("AddToWishList", filter);
                responseTask.Wait();

                var result = responseTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    var content = result.Content.ReadAsStringAsync();
                    AddToWishListResponseModel resutl = Newtonsoft.Json.JsonConvert.DeserializeObject <AddToWishListResponseModel>(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 <AddToWishListResponseModel> AddToWishList([FromBody] AddToWishListInputModel data)
        {
            AddToWishListResponseModel res = new AddToWishListResponseModel();

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

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

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

                return(res);
            }
        }