public void UpdateCategory(int id, string name, string description) { try { name = name.TrimEnd().TrimStart(); description = description.TrimEnd().TrimStart(); } catch (Exception) { throw new Exception("No es posible registrar la Categoría"); } CategoriesDAO dao = new CategoriesDAO(); List <Category> categories = GetAllCategories(); //Category updateCategory = dao.GetCategory(id); Category updateCategory = categories.Find(c => c.id.Equals(id)); if (updateCategory != null) { if (categories.FindAll(c => (c.name.ToUpperInvariant().Equals(name.ToUpperInvariant())) && (c.id != id)).Count > 0) { throw new Exception("Ya existe una Categoría con este nombre"); } updateCategory.name = name; updateCategory.description = description; int result = dao.UpdateCategory(updateCategory); if (result < 1) { throw new Exception("No es posible actualizar la Categoría"); } } else { throw new Exception("El id de la Categoría a actualizar no es válido"); } }