public IHttpActionResult DeleteMunition(string id) { Munition munition = db.Munitions.Find(id); if (munition == null) { return(NotFound()); } if (db.MunitionsInventory.Any(x => x.metaDataID == munition.MunitionID)) { return(BadRequest("This specification cannot be deleted -- there are inventory items that use this specification.")); } db.Munitions.Remove(munition); db.SaveChanges(); munition.DeleteFiles(munition.GetType().GetProperties().Where(p => properties.Contains(p.Name)).ToArray(), "Munition"); return(Ok(munition)); }