Ejemplo n.º 1
0
        public async Task <EResponseBase <Seller_Response> > Add(Seller_Request model)
        {
            var request = JsonConvert.SerializeObject(model);
            var content = new StringContent(request, Encoding.UTF8, "application/json");

            var client = new HttpClient();

            client.BaseAddress = new Uri(_urlBase);
            var url = string.Concat(_endPoint);

            var response = client.PostAsync(url, content).Result;

            if (response.StatusCode == HttpStatusCode.OK)
            {
                var result = await response.Content.ReadAsStringAsync();

                return(JsonConvert.DeserializeObject <EResponseBase <Seller_Response> >(result));
            }
            else
            {
                return(new EResponseBase <Seller_Response>
                {
                    IsSuccess = false,
                    Code = (int)response.StatusCode,
                    Message = "Error"
                });
            }
        }
Ejemplo n.º 2
0
 public ActionResult Add(Seller_Request model)
 {
     if (model.SellerID == 0)
     {
         var response = Task.Run(() => proxy.Add(model));
         return(Json(response, JsonRequestBehavior.AllowGet));
     }
     else
     {
         var response = Task.Run(() => proxy.Update(model));
         return(Json(response, JsonRequestBehavior.AllowGet));
     }
 }