public async Task <Category> UpdateAsync(int id, UpdateCategoryDto categoryToUpdate)
        {
            if (id < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(id), id, "Id cannot be lower than 1.");
            }

            if (categoryToUpdate == null)
            {
                throw new ArgumentNullException(nameof(categoryToUpdate));
            }

            if (categoryToUpdate.Name.Length > 35)
            {
                throw new ArgumentOutOfRangeException(nameof(categoryToUpdate.Name), categoryToUpdate.Name, "Category name length cannot be greater than 35.");
            }

            if (!await _categoriesRepository.ExistsById(id))
            {
                throw new DataNotFoundException($"Category Id:{id} doesn't exists.");
            }

            if (await _categoriesRepository.ExistsByName(categoryToUpdate.Name))
            {
                throw new ArgumentException(nameof(categoryToUpdate.Name), $"Category {categoryToUpdate.Name} already exists.");
            }

            return(await _categoriesRepository.UpdateAsync(id, categoryToUpdate));
        }