Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 240d2e5b

Přidáno uživatelem Milan Hotovec před téměř 4 roky(ů)

Goals initial connected

Zobrazit rozdíly:

src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/DependencyInjection.cs
1 1
using ExtCore.Infrastructure.Actions;
2
using Leuze.Core.Application.Configuration;
3
using Leuze.Core.Domain.Domains.Users;
4
using Leuze.Core.Infrastructure.Persistence;
5
using Leuze.Modules.Goal.Domain.Domains;
2 6
using Leuze.Modules.Goal.Infrastructure.Persistence.Extensions;
3 7
using Microsoft.AspNetCore.Builder;
4 8
using Microsoft.Extensions.DependencyInjection;
9
using Microsoft.Extensions.Options;
5 10
using System;
11
using System.Linq;
6 12

  
7 13
namespace Leuze.Modules.Goal.Infrastructure.Persistence
8 14
{
......
44 50
        /// <param name="serviceProvider"></param>
45 51
        public void Execute(IApplicationBuilder applicationBuilder, IServiceProvider serviceProvider)
46 52
        {
53
            using (var serviceScope = serviceProvider.GetRequiredService<IServiceScopeFactory>().CreateScope())
54
            {
55
                var context = serviceScope.ServiceProvider.GetRequiredService<LeuzeDbContext>();
56
                var appSettings = serviceScope.ServiceProvider.GetRequiredService<IOptions<AppSettings>>().Value;
47 57

  
58
                var user = context.Set<DomainUser>().Where(item => item.EmailAddress.Email == "ma@test.cz").FirstOrDefault();
59
                GoalDefinition gd = new GoalDefinition(user, user, "Test Goal definition", DateTime.Now, DateTime.Now.AddDays(10));
60
                context.Add(gd);
61
                context.SaveChanges();
62
            }
48 63
        }
49 64
    }
50 65
}

Také k dispozici: Unified diff