public object Delete(int id, string category_code)
        {
            string token = Request.Headers.Authorization == null ? "" : Request.Headers.Authorization.ToString();

            Logger.Info(Request.RequestUri + "  ||  Method: " + Request.Method, Request.Headers.ToString(), JsonConvert.SerializeObject(id), Level.INFO);

            ResponseDTO Response            = new ResponseDTO();
            ResponseDTO ResponseStore       = new ResponseDTO();
            ResponseDTO ResponseLegislation = new ResponseDTO();
            ErrorDTO    ErrorResponse       = new ErrorDTO();
            CategoryDTO UserResponse        = new CategoryDTO();

            ResponseStore       = StoreBUS.GetAllStore("", category_code, "", "", 1, 100);
            ResponseLegislation = LegislationBUS.GetAllLegislation("", "", category_code, 1, 100);

            if (ResponseStore.Data == null && ResponseLegislation.Data == null)
            {
                Response = CategoryBUS.DeleteCategory(id);
            }
            else
            {
                ErrorResponse.Code    = 400;
                ErrorResponse.Message = "Industry being used";
                Response.Error        = ErrorResponse;
            }

            return(Response);
        }
Пример #2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            int         rowIndex = dgvCategoryList.CurrentCell.RowIndex;
            CategoryDTO category = new CategoryDTO {
                ID = int.Parse(dtCategories.Rows[rowIndex]["ID"].ToString())
            };

            if (MessageBox.Show("Do you want to delete Category-" + category.ID + "?", "Delete Category", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                if (categoryBUS.DeleteCategory(category))
                {
                    MessageBox.Show("Delete category was successfull!", "Delete Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    LoadData();
                }
                else
                {
                    MessageBox.Show("Delete category was fail!", "Delete Result", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }