Merge pull request #6722 from dpavlos/fix_6679

[6679] Check if org exists before delete it
This commit is contained in:
Carl Bergquist
2016-11-29 21:12:02 +01:00
committed by GitHub
2 changed files with 9 additions and 0 deletions

View File

@@ -152,6 +152,9 @@ func updateOrgAddressHelper(form dtos.UpdateOrgAddressForm, orgId int64) Respons
// GET /api/orgs/:orgId
func DeleteOrgById(c *middleware.Context) Response {
if err := bus.Dispatch(&m.DeleteOrgCommand{Id: c.ParamsInt64(":orgId")}); err != nil {
if err == m.ErrOrgNotFound {
return ApiError(404, "Failed to delete organization. ID not found", nil)
}
return ApiError(500, "Failed to update organization", err)
}
return ApiSuccess("Organization deleted")