Exemplo n.º 1
0
        public async Task <ActionResult> EditCategory(int id)
        {
            var response = await _categoryApiClient.getCategorybyIdAsync(id);

            string result = await response.Content.ReadAsStringAsync();

            switch ((int)response.StatusCode)
            {
            case (int)HttpStatusCode.OK:
                var category = JsonConvert.DeserializeObject <Category>(result);
                return(Json(new { Success = true, data = category }, JsonRequestBehavior.AllowGet));

            case (int)HttpStatusCode.NotFound:
                return(HttpNotFound());

            default:
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
        }