コード例 #1
0
        public async Task AddAsync(Regulation regulation)
        {
            var regulations = await GetAllAsync();

            if (regulations.Any(x => x.Description == regulation.Description))
            {
                AddNotification("Já existe outro regulamento cadastrado com essa descrição.");
            }

            if (ValidateEntity(regulation))
            {
                _regulationRepository.Add(regulation);

                if (!await CommitAsync())
                {
                    AddNotification("Não foi possível cadastrar o regulamento.");
                }
            }
        }