示例#1
0
        public async Task AddSpecialityTask(SpecialityRequest request)
        {
            using (var context = _serviceProvider.GetService <DatabaseContext>())
            {
                var specialityEntity = new SpecialityEntity(request);

                await context.Specialtys.AddAsync(specialityEntity);

                await context.SaveChangesAsync();
            }
        }
示例#2
0
        ///<inheritdoc/>
        public async Task AddSpecialityAsync(SpecialityRequest request, CancellationToken cancellationToken)
        {
            using (var scope = _serviceProvider.CreateScope())
                using (var context = scope.ServiceProvider.GetRequiredService <DatabaseContext>())
                {
                    var specialityEntity = new SpecialityEntity(request);

                    await context.Specialties.AddAsync(specialityEntity, cancellationToken).ConfigureAwait(false);

                    await context.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
                }
        }