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;
|
6
|
using Leuze.Modules.Goal.Infrastructure.Persistence.Extensions;
|
7
|
using Microsoft.AspNetCore.Builder;
|
8
|
using Microsoft.Extensions.DependencyInjection;
|
9
|
using Microsoft.Extensions.Options;
|
10
|
using System;
|
11
|
using System.Linq;
|
12
|
|
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
|
public void Execute(IApplicationBuilder applicationBuilder, IServiceProvider serviceProvider)
|
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;
|
57
|
|
58
|
//TODO: This is debug delet this
|
59
|
var user = context.Set<DomainUser>().Where(item => item.EmailAddress.Email == "ma@test.cz").FirstOrDefault();
|
60
|
GoalDefinition gd = new GoalDefinition(user, user, new GlobalDefinitionArea(user, DateTime.Now, DateTime.Now.AddDays(10)) ,"Test Goal definition");
|
61
|
context.Add(gd);
|
62
|
context.SaveChanges();
|
63
|
}
|
64
|
}
|
65
|
}
|
66
|
}
|