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

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

            switch ((int)response.StatusCode)
            {
            case (int)HttpStatusCode.OK:
                return(Json(new { Success = true }, JsonRequestBehavior.AllowGet));

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

            default:
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
        }
Exemplo n.º 2
0
        private void btnRemove_ClickAsync(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in dgvEmploye.SelectedRows)
            {
                try
                {
                    int id = Convert.ToInt32(row.Cells[0].Value.ToString());
                    _categoryApiClient.DeleteAsync(id);

                    CetegoriesRead();
                    //var response =await _categoryApiClient.DeleteAsync(id);
                    //string result =await response.Content.ReadAsStringAsync();
                }
                catch (Exception ex)
                {
                    throw;
                }
            }

            CetegoriesRead();
        }