1 |
b80b186b
|
Milan Hotovec
|
using ExtCore.Infrastructure.Actions;
|
2 |
240d2e5b
|
Milan Hotovec
|
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;
|
6 |
6391f3f2
|
Dominik Chlouba
|
using Leuze.Modules.Goal.Infrastructure.Persistence.Extensions;
|
7 |
b80b186b
|
Milan Hotovec
|
using Microsoft.AspNetCore.Builder;
|
8 |
|
|
using Microsoft.Extensions.DependencyInjection;
|
9 |
240d2e5b
|
Milan Hotovec
|
using Microsoft.Extensions.Options;
|
10 |
b80b186b
|
Milan Hotovec
|
using System;
|
11 |
240d2e5b
|
Milan Hotovec
|
using System.Linq;
|
12 |
b80b186b
|
Milan Hotovec
|
|
13 |
|
|
namespace Leuze.Modules.Goal.Infrastructure.Persistence
|
14 |
|
|
{
|
15 |
|
|
/// <summary>
|
16 |
|
|
///
|
17 |
|
|
/// </summary>
|
18 |
|
|
public class ServicesConfiguration : IConfigureServicesAction
|
19 |
|
|
{
|
20 |
|
|
/// <summary>
|
21 |
|
|
///
|
22 |
|
|
/// </summary>
|
23 |
|
|
public int Priority => 1000;
|
24 |
|
|
|
25 |
|
|
/// <summary>
|
26 |
|
|
///
|
27 |
|
|
/// </summary>
|
28 |
|
|
/// <param name="services"></param>
|
29 |
|
|
/// <param name="serviceProvider"></param>
|
30 |
|
|
public void Execute(IServiceCollection services, IServiceProvider serviceProvider)
|
31 |
|
|
{
|
32 |
|
|
services.AddRepositories();
|
33 |
|
|
}
|
34 |
|
|
}
|
35 |
|
|
|
36 |
|
|
/// <summary>
|
37 |
|
|
///
|
38 |
|
|
/// </summary>
|
39 |
|
|
public class ApplicationConfiguration : IConfigureAction
|
40 |
|
|
{
|
41 |
|
|
/// <summary>
|
42 |
|
|
///
|
43 |
|
|
/// </summary>
|
44 |
|
|
public int Priority => 11000;
|
45 |
|
|
|
46 |
|
|
/// <summary>
|
47 |
|
|
///
|
48 |
|
|
/// </summary>
|
49 |
|
|
/// <param name="applicationBuilder"></param>
|
50 |
|
|
/// <param name="serviceProvider"></param>
|
51 |
6391f3f2
|
Dominik Chlouba
|
public void Execute(IApplicationBuilder applicationBuilder, IServiceProvider serviceProvider)
|
52 |
|
|
{
|
53 |
240d2e5b
|
Milan Hotovec
|
using (var serviceScope = serviceProvider.GetRequiredService<IServiceScopeFactory>().CreateScope())
|
54 |
|
|
{
|
55 |
|
|
var context = serviceScope.ServiceProvider.GetRequiredService<LeuzeDbContext>();
|
56 |
|
|
var appSettings = serviceScope.ServiceProvider.GetRequiredService<IOptions<AppSettings>>().Value;
|
57 |
6391f3f2
|
Dominik Chlouba
|
|
58 |
240d2e5b
|
Milan Hotovec
|
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 |
|
|
}
|
63 |
6391f3f2
|
Dominik Chlouba
|
}
|
64 |
b80b186b
|
Milan Hotovec
|
}
|
65 |
|
|
}
|