public ActionResult <JsonResponse> DeleteAuthenticatedSiteComponentMethod(ComponentReference Component) { if (Component.component_type == "p_box") { try{ ParagraphBox paragraph_box = dbQuery.DeleteParagraphBox(Component.component_id); Site parent_site = dbQuery.QueryFeaturelessSiteById(paragraph_box.site_id); _dataLimiter.RemoveFromDataPlan(paragraph_box, parent_site.admin_id); JsonResponse r = new JsonSuccess("Paragraph box deleted sucessfully!"); return(r); }catch { JsonFailure f = new JsonFailure($"Unable to find paragraph box id {Component.component_id}"); return(StatusCode(400, f)); } } else if (Component.component_type == "image") { try{ Image image = dbQuery.DeleteImage(Component.component_id); Site parent_site = dbQuery.QueryFeaturelessSiteById(image.site_id); _dataLimiter.RemoveFromDataPlan(image, parent_site.admin_id); JsonResponse r = new JsonSuccess("Image deleted sucessfully!"); return(r); }catch { JsonFailure f = new JsonFailure($"Unable to find image id {Component.component_id}"); return(StatusCode(400, f)); } } else if (Component.component_type == "portrait") { try{ Portrait portrait = dbQuery.DeletePortrait(Component.component_id); Site parent_site = dbQuery.QueryFeaturelessSiteById(portrait.site_id); _dataLimiter.RemoveFromDataPlan(portrait, parent_site.admin_id); JsonResponse r = new JsonSuccess("Portrait component deleted sucessfully!"); return(r); }catch { JsonFailure f = new JsonFailure($"Unable to find portrait id {Component.component_id}"); return(StatusCode(400, f)); } } else if (Component.component_type == "2c_box") { try{ TwoColumnBox two_column_box = dbQuery.DeleteTwoColumnBox(Component.component_id); Site parent_site = dbQuery.QueryFeaturelessSiteById(two_column_box.site_id); _dataLimiter.RemoveFromDataPlan(two_column_box, parent_site.admin_id); JsonResponse r = new JsonSuccess("Two Column Box component deleted sucessfully!"); return(r); }catch { JsonFailure f = new JsonFailure($"Unable to find two column box id {Component.component_id}"); return(StatusCode(400, f)); } } else if (Component.component_type == "link_box") { try{ LinkBox link_box = dbQuery.DeleteLinkBox(Component.component_id); Site parent_site = dbQuery.QueryFeaturelessSiteById(link_box.site_id); _dataLimiter.RemoveFromDataPlan(link_box, parent_site.admin_id); JsonResponse r = new JsonSuccess("Link Box component deleted sucessfully!"); return(r); }catch { JsonFailure f = new JsonFailure($"Unable to find link box id {Component.component_id}"); return(StatusCode(400, f)); } } else { JsonFailure f = new JsonFailure("Type mismatch. Type does not match any known components."); return(StatusCode(400, f)); } }