Rename directories and projects
This commit is contained in:
56
Back/skydiveLogs-api.Infrastructure/AircraftRepository.cs
Normal file
56
Back/skydiveLogs-api.Infrastructure/AircraftRepository.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using LiteDB;
|
||||
|
||||
using skydiveLogs_api.Domain;
|
||||
using skydiveLogs_api.DomainService.Repositories;
|
||||
using skydiveLogs_api.Infrastructure.Interfaces;
|
||||
|
||||
|
||||
namespace skydiveLogs_api.Infrastructure
|
||||
{
|
||||
public class AircraftRepository : IAircraftRepository
|
||||
{
|
||||
public AircraftRepository(IDataProvider dataProvider)
|
||||
{
|
||||
_dataProvider = dataProvider;
|
||||
_col = _dataProvider.CollOfAircraft;
|
||||
}
|
||||
|
||||
public IEnumerable<Aircraft> GetAll()
|
||||
{
|
||||
return _col.FindAll().ToList();
|
||||
}
|
||||
|
||||
public Aircraft GetById(int id)
|
||||
{
|
||||
return _col.FindById(new BsonValue(id));
|
||||
}
|
||||
|
||||
public bool Update(Aircraft aircraft)
|
||||
{
|
||||
return _col.Update(aircraft);
|
||||
}
|
||||
|
||||
public bool Add(Aircraft newAircraft)
|
||||
{
|
||||
var result = true;
|
||||
|
||||
try
|
||||
{
|
||||
_col.Insert(newAircraft);
|
||||
}
|
||||
catch
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private readonly IDataProvider _dataProvider;
|
||||
|
||||
private readonly ILiteCollection<Aircraft> _col;
|
||||
}
|
||||
}
|
||||
56
Back/skydiveLogs-api.Infrastructure/DropZoneRepository.cs
Normal file
56
Back/skydiveLogs-api.Infrastructure/DropZoneRepository.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using LiteDB;
|
||||
|
||||
using skydiveLogs_api.Domain;
|
||||
using skydiveLogs_api.DomainService.Repositories;
|
||||
using skydiveLogs_api.Infrastructure.Interfaces;
|
||||
|
||||
|
||||
namespace skydiveLogs_api.Infrastructure
|
||||
{
|
||||
public class DropZoneRepository : IDropZoneRepository
|
||||
{
|
||||
public DropZoneRepository(IDataProvider dataProvider)
|
||||
{
|
||||
_dataProvider = dataProvider;
|
||||
_col = _dataProvider.CollOfDropZone;
|
||||
}
|
||||
|
||||
public IEnumerable<DropZone> GetAll()
|
||||
{
|
||||
return _col.FindAll().ToList();
|
||||
}
|
||||
|
||||
public DropZone GetById(int id)
|
||||
{
|
||||
return _col.FindById(new BsonValue(id));
|
||||
}
|
||||
|
||||
public bool Update(DropZone updatedDz)
|
||||
{
|
||||
return _col.Update(updatedDz);
|
||||
}
|
||||
|
||||
public bool Add(DropZone newDz)
|
||||
{
|
||||
var result = true;
|
||||
|
||||
try
|
||||
{
|
||||
_col.Insert(newDz);
|
||||
}
|
||||
catch
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private readonly IDataProvider _dataProvider;
|
||||
|
||||
private readonly ILiteCollection<DropZone> _col;
|
||||
}
|
||||
}
|
||||
63
Back/skydiveLogs-api.Infrastructure/GearRepository.cs
Normal file
63
Back/skydiveLogs-api.Infrastructure/GearRepository.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using LiteDB;
|
||||
|
||||
using skydiveLogs_api.Domain;
|
||||
using skydiveLogs_api.DomainService.Repositories;
|
||||
using skydiveLogs_api.Infrastructure.Interfaces;
|
||||
|
||||
|
||||
namespace skydiveLogs_api.Infrastructure
|
||||
{
|
||||
public class GearRepository : IGearRepository
|
||||
{
|
||||
public GearRepository(IDataProvider dataProvider)
|
||||
{
|
||||
_dataProvider = dataProvider;
|
||||
_col = _dataProvider.CollOfGear;
|
||||
}
|
||||
|
||||
public IEnumerable<Gear> GetAll()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerable<Gear> GetAll(User user)
|
||||
{
|
||||
return _col.Include(x => x.User)
|
||||
.Query()
|
||||
.Where(j => j.User.Id == user.Id)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public Gear GetById(int id)
|
||||
{
|
||||
return _col.FindById(new BsonValue(id));
|
||||
}
|
||||
|
||||
public bool Update(Gear updatedGear)
|
||||
{
|
||||
return _col.Update(updatedGear);
|
||||
}
|
||||
|
||||
public bool Add(Gear newGear)
|
||||
{
|
||||
var result = true;
|
||||
|
||||
try
|
||||
{
|
||||
_col.Insert(newGear);
|
||||
}
|
||||
catch
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private readonly IDataProvider _dataProvider;
|
||||
|
||||
private readonly ILiteCollection<Gear> _col;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using LiteDB;
|
||||
|
||||
using skydiveLogs_api.Domain;
|
||||
|
||||
|
||||
namespace skydiveLogs_api.Infrastructure.Interfaces
|
||||
{
|
||||
public interface IDataProvider
|
||||
{
|
||||
ILiteCollection<T> GetCollection<T>();
|
||||
|
||||
void Close();
|
||||
|
||||
ILiteCollection<Aircraft> CollOfAircraft { get; }
|
||||
|
||||
ILiteCollection<DropZone> CollOfDropZone { get; }
|
||||
|
||||
ILiteCollection<Gear> CollOfGear { get; }
|
||||
|
||||
ILiteCollection<JumpType> CollOfJumpType { get; }
|
||||
|
||||
ILiteCollection<Jump> CollOfJump { get; }
|
||||
|
||||
ILiteCollection<User> CollOfUser { get; }
|
||||
|
||||
ILiteCollection<UserImage> CollOfImage { get; }
|
||||
}
|
||||
}
|
||||
67
Back/skydiveLogs-api.Infrastructure/JumpRepository.cs
Normal file
67
Back/skydiveLogs-api.Infrastructure/JumpRepository.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using LiteDB;
|
||||
|
||||
using skydiveLogs_api.Domain;
|
||||
using skydiveLogs_api.DomainService.Repositories;
|
||||
using skydiveLogs_api.Infrastructure.Interfaces;
|
||||
|
||||
|
||||
namespace skydiveLogs_api.Infrastructure
|
||||
{
|
||||
public class JumpRepository : IJumpRepository
|
||||
{
|
||||
public JumpRepository(IDataProvider dataProvider)
|
||||
{
|
||||
_dataProvider = dataProvider;
|
||||
_col = _dataProvider.CollOfJump;
|
||||
}
|
||||
|
||||
public IEnumerable<Jump> GetAll(User user)
|
||||
{
|
||||
return _col.Include(x => x.Aircraft)
|
||||
.Include(x => x.DropZone)
|
||||
.Include(x => x.Gear)
|
||||
.Include(x => x.JumpType)
|
||||
.Include(x => x.User)
|
||||
.Query()
|
||||
.Where(j => j.User.Id == user.Id)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public Jump GetById(int id)
|
||||
{
|
||||
return _col.FindById(new BsonValue(id));
|
||||
}
|
||||
|
||||
public bool Add(Jump newJump)
|
||||
{
|
||||
var result = true;
|
||||
|
||||
try
|
||||
{
|
||||
_col.Insert(newJump);
|
||||
}
|
||||
catch
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool Update(Jump updatedJump)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerable<Jump> GetAll()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
private readonly IDataProvider _dataProvider;
|
||||
|
||||
private readonly ILiteCollection<Jump> _col;
|
||||
}
|
||||
}
|
||||
56
Back/skydiveLogs-api.Infrastructure/JumpTypeRepository.cs
Normal file
56
Back/skydiveLogs-api.Infrastructure/JumpTypeRepository.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using LiteDB;
|
||||
|
||||
using skydiveLogs_api.Domain;
|
||||
using skydiveLogs_api.DomainService.Repositories;
|
||||
using skydiveLogs_api.Infrastructure.Interfaces;
|
||||
|
||||
|
||||
namespace skydiveLogs_api.Infrastructure
|
||||
{
|
||||
public class JumpTypeRepository : IJumpTypeRepository
|
||||
{
|
||||
public JumpTypeRepository(IDataProvider dataProvider)
|
||||
{
|
||||
_dataProvider = dataProvider;
|
||||
_col = _dataProvider.CollOfJumpType;
|
||||
}
|
||||
|
||||
public IEnumerable<JumpType> GetAll()
|
||||
{
|
||||
return _col.FindAll().ToList();
|
||||
}
|
||||
|
||||
public JumpType GetById(int id)
|
||||
{
|
||||
return _col.FindById(new BsonValue(id));
|
||||
}
|
||||
|
||||
public bool Update(JumpType updatedJumpType)
|
||||
{
|
||||
return _col.Update(updatedJumpType);
|
||||
}
|
||||
|
||||
public bool Add(JumpType newJumpType)
|
||||
{
|
||||
var result = true;
|
||||
|
||||
try
|
||||
{
|
||||
_col.Insert(newJumpType);
|
||||
}
|
||||
catch
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private readonly IDataProvider _dataProvider;
|
||||
|
||||
private readonly ILiteCollection<JumpType> _col;
|
||||
}
|
||||
}
|
||||
52
Back/skydiveLogs-api.Infrastructure/LiteDbProvider.cs
Normal file
52
Back/skydiveLogs-api.Infrastructure/LiteDbProvider.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using LiteDB;
|
||||
|
||||
using skydiveLogs_api.Domain;
|
||||
using skydiveLogs_api.Infrastructure.Interfaces;
|
||||
|
||||
|
||||
namespace skydiveLogs_api.Infrastructure
|
||||
{
|
||||
public class LiteDbProvider : IDataProvider
|
||||
{
|
||||
public LiteDbProvider(string connectionString)
|
||||
{
|
||||
_db = new LiteDatabase(connectionString);
|
||||
|
||||
BsonMapper.Global.Entity<Jump>().DbRef(x => x.JumpType, "JumpType");
|
||||
BsonMapper.Global.Entity<Jump>().DbRef(x => x.Aircraft, "Aircraft");
|
||||
BsonMapper.Global.Entity<Jump>().DbRef(x => x.DropZone, "DropZone");
|
||||
BsonMapper.Global.Entity<Jump>().DbRef(x => x.Gear, "Gear");
|
||||
BsonMapper.Global.Entity<Jump>().DbRef(x => x.User, "User");
|
||||
|
||||
BsonMapper.Global.Entity<UserImage>().DbRef(x => x.User, "User");
|
||||
|
||||
BsonMapper.Global.Entity<Gear>().DbRef(x => x.User, "User");
|
||||
}
|
||||
|
||||
public ILiteCollection<T> GetCollection<T>()
|
||||
{
|
||||
return _db.GetCollection<T>();
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
_db.Dispose();
|
||||
}
|
||||
|
||||
private readonly LiteDatabase _db;
|
||||
|
||||
public ILiteCollection<Aircraft> CollOfAircraft => _db.GetCollection<Aircraft>();
|
||||
|
||||
public ILiteCollection<DropZone> CollOfDropZone => _db.GetCollection<DropZone>();
|
||||
|
||||
public ILiteCollection<Gear> CollOfGear => _db.GetCollection<Gear>();
|
||||
|
||||
public ILiteCollection<JumpType> CollOfJumpType => _db.GetCollection<JumpType>();
|
||||
|
||||
public ILiteCollection<Jump> CollOfJump => _db.GetCollection<Jump>();
|
||||
|
||||
public ILiteCollection<User> CollOfUser => _db.GetCollection<User>();
|
||||
|
||||
public ILiteCollection<UserImage> CollOfImage => _db.GetCollection<UserImage>();
|
||||
}
|
||||
}
|
||||
63
Back/skydiveLogs-api.Infrastructure/UserImageRepository.cs
Normal file
63
Back/skydiveLogs-api.Infrastructure/UserImageRepository.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using LiteDB;
|
||||
|
||||
using skydiveLogs_api.Domain;
|
||||
using skydiveLogs_api.DomainService.Repositories;
|
||||
using skydiveLogs_api.Infrastructure.Interfaces;
|
||||
|
||||
|
||||
namespace skydiveLogs_api.Infrastructure
|
||||
{
|
||||
public class UserImageRepository : IUserImageRepository
|
||||
{
|
||||
public UserImageRepository(IDataProvider dataProvider)
|
||||
{
|
||||
_dataProvider = dataProvider;
|
||||
_col = _dataProvider.CollOfImage;
|
||||
}
|
||||
|
||||
public IEnumerable<UserImage> GetAll()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public IEnumerable<UserImage> GetAll(User user)
|
||||
{
|
||||
return _col.Include(x => x.User)
|
||||
.Query()
|
||||
.Where(j => j.User == user)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public UserImage GetById(int id)
|
||||
{
|
||||
return _col.FindById(new BsonValue(id));
|
||||
}
|
||||
|
||||
public bool Update(UserImage image)
|
||||
{
|
||||
return _col.Update(image);
|
||||
}
|
||||
|
||||
public bool Add(UserImage newImage)
|
||||
{
|
||||
var result = true;
|
||||
|
||||
try
|
||||
{
|
||||
_col.Insert(newImage);
|
||||
}
|
||||
catch
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private readonly IDataProvider _dataProvider;
|
||||
|
||||
private readonly ILiteCollection<UserImage> _col;
|
||||
}
|
||||
}
|
||||
61
Back/skydiveLogs-api.Infrastructure/UserRepository.cs
Normal file
61
Back/skydiveLogs-api.Infrastructure/UserRepository.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using LiteDB;
|
||||
|
||||
using skydiveLogs_api.Domain;
|
||||
using skydiveLogs_api.DomainService.Repositories;
|
||||
using skydiveLogs_api.Infrastructure.Interfaces;
|
||||
|
||||
|
||||
namespace skydiveLogs_api.Infrastructure
|
||||
{
|
||||
public class UserRepository : IUserRepository
|
||||
{
|
||||
public UserRepository(IDataProvider dataProvider)
|
||||
{
|
||||
_dataProvider = dataProvider;
|
||||
_col = _dataProvider.CollOfUser;
|
||||
}
|
||||
|
||||
public User GetByLogin(string login, string password)
|
||||
{
|
||||
return _col.FindOne(u => u.Login == login && u.Password == password);
|
||||
}
|
||||
|
||||
public bool Add(User newUser)
|
||||
{
|
||||
var result = true;
|
||||
|
||||
try
|
||||
{
|
||||
_col.Insert(newUser);
|
||||
}
|
||||
catch
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public IEnumerable<User> GetAll()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public User GetById(int id)
|
||||
{
|
||||
return _col.FindById(new BsonValue(id));
|
||||
}
|
||||
|
||||
public bool Update(User updated)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private readonly IDataProvider _dataProvider;
|
||||
|
||||
private readonly ILiteCollection<User> _col;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<RootNamespace>skydiveLogs_api.Infrastructure</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="LiteDB" Version="5.0.10" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\skydiveLogs-api.DomainService\skydiveLogs-api.DomainService.csproj" />
|
||||
<ProjectReference Include="..\skydiveLogs-api.Domain\skydiveLogs-api.Domain.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user