Exemplo n.º 1
0
        public async Task <Formation> AddAsync(string name, string abreviation, Guid createdBy)
        {
            if (_formationRepository.GetByNameAsync(name).Result != null ||
                _formationRepository.GetByAbreviationAsync(abreviation).Result != null)
            {
                throw new RepartException("formation_already_exist",
                                          $"Une formation semble déjà exister ({name}, {abreviation.ToUpperInvariant()})");
            }

            var formation        = new Domain.Models.Formation(name, abreviation);
            var formationHistory = new Domain.Models.FormationHistory(createdBy, formation);

            await _formationRepository.AddAsync(formation);

            await _formationHistoryRepository.AddAsync(formationHistory);

            return(MapFormation(formation));
        }