public IActionResult GetProductsByCategory(int id) { if (id <= 0) { throw new ArgumentOutOfRangeException("Category id is not valid"); } try { var products = productLogic.GetAllProductsByCategory(id); string jsonstring = JsonConvert.SerializeObject(products); byte[] encrypted = encryptDecrypt.EncryptStringToBytes_Aes(jsonstring); return(Ok(encrypted)); } catch (Exception e) { return(NotFound(e)); } }