Добавьте файлы проекта.
This commit is contained in:
17
Data/Data.csproj
Normal file
17
Data/Data.csproj
Normal file
@@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Services\Services.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Models\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
13
Data/Extentions/ServiceCollectionExtentions.cs
Normal file
13
Data/Extentions/ServiceCollectionExtentions.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Services.Tickets;
|
||||
|
||||
namespace Data.Extentions;
|
||||
|
||||
public static class ServiceCollectionExtentions
|
||||
{
|
||||
public static void TyAddFakeTicketRepository(this IServiceCollection services)
|
||||
{
|
||||
services.TryAddScoped<ITicketRepository, FakeTicketRepository>();
|
||||
}
|
||||
}
|
||||
21
Data/FakeTicketRepository.cs
Normal file
21
Data/FakeTicketRepository.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Services.Tickets;
|
||||
using Services.Tickets.Models;
|
||||
|
||||
namespace Data;
|
||||
|
||||
internal class FakeTicketRepository : ITicketRepository
|
||||
{
|
||||
private readonly List<LotteryTicket> _lotteryTickets = new List<LotteryTicket>();
|
||||
public Task<long> AddNewTicket(LotteryTicket ticket)
|
||||
{
|
||||
var id =(long)Random.Shared.Next(1, 100);
|
||||
ticket.Id = id;
|
||||
_lotteryTickets.Add(ticket);
|
||||
return Task.FromResult(id);
|
||||
}
|
||||
|
||||
public Task<List<LotteryTicket>> GetAllTickets()
|
||||
{
|
||||
return Task.FromResult(_lotteryTickets);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user