public async Task AddGroup(ProductGroupDataEntity productGroupDataEntity)
 {
     using (var connection = new SqlConnection(_connectionString))
     {
         await connection.ExecuteAsync(_insertStatement, productGroupDataEntity);
     }
 }
示例#2
0
        public Task AddGroup(ProductGroupDataEntity productGroupDataEntity)
        {
            if (_productGroupDataEntities.Any(pg => pg.Id == productGroupDataEntity.Id))
            {
                throw new DuplicateResourceException($"A product group with id {productGroupDataEntity.Id} already exists");
            }

            if (_productGroupDataEntities.Any(pg => pg.Name == productGroupDataEntity.Name))
            {
                throw new DuplicateResourceException($"A product group with name {productGroupDataEntity.Name} already exists");
            }

            _productGroupDataEntities.Add(productGroupDataEntity);

            return(Task.CompletedTask);
        }