/
ContratosImpl.cs
86 lines (70 loc) · 2.48 KB
/
ContratosImpl.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using Fivet.Dao;
using Fivet.ZeroIce.model;
using Ice;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace Fivet.ZeroIce
{
/// <summary>
/// Implementation of the Contratos.
/// </summary>
public class ContratosImpl : ContratosDisp_
{
/// <summary>
/// The logger
/// </summary>
private readonly ILogger<ContratosImpl> _logger;
/// <summary>
/// The provider of DbContext
/// </summary>
private readonly IServiceScopeFactory _serviceScopeFactory;
/// <summary>
/// The Contructor.
/// </summary>
/// <param name="logger"></param>
/// <param name="serviceProviderFactory"></param>
public ContratosImpl(ILogger<ContratosImpl> logger,
IServiceScopeFactory serviceProviderFactory)
{
_logger = logger;
_logger.LogDebug("Building the ContratosImpl ..");
_serviceScopeFactory = serviceProviderFactory;
// Create the database
_logger.LogInformation("Creating the Database ..");
using (var scope = _serviceScopeFactory.CreateScope())
{
FivetContext fc = scope.ServiceProvider.GetService<FivetContext>();
fc.Database.EnsureCreated();
fc.SaveChanges();
}
_logger.LogDebug("Done. ");
}
public override Ficha obtenerFicha(int numero, Current current = null)
{
throw new System.NotImplementedException();
}
public override bool registrarFicha(Ficha ficha, Current current = null)
{
throw new System.NotImplementedException();
}
public override bool registrarDuenio(Persona persona, Current current = null)
{
// Using the local scope
using (var scope = _serviceScopeFactory.CreateScope())
{
FivetContext fc = scope.ServiceProvider.GetService<FivetContext>();
fc.Personas.Add(persona);
fc.SaveChanges();
return true;
}
}
public override bool registrarControl(Control control, Current current = null)
{
throw new System.NotImplementedException();
}
public override bool agregarFoto(Foto foto, Current current = null)
{
throw new System.NotImplementedException();
}
}
}