public async Task AddCategorie(Categorie categorie) { var rowsCount = await _categorieRepository.CountAsync(); var categorieAvecLeLibelle = _categorieRepository.GetByLibelleAsync(categorie.Libelle); if (categorieAvecLeLibelle != null) { throw new RecordAlreadyExistException(); } var maxId = 1; if (rowsCount > 0) { maxId = _categorieRepository.MaxId(); maxId += 1; } categorie.SetId(maxId); categorie.DateSaisie = DateTime.Now; categorie.DateModification = DateTime.Now; try { await _categorieRepository.AddAsync(categorie); } catch (Exception ex) { throw new Exception(ex.Message, ex); } }