Auto clean code

This commit is contained in:
Sébastien André
2021-04-22 23:31:08 +02:00
parent 1c66efa4e8
commit 0d136a938a
29 changed files with 325 additions and 227 deletions

View File

@@ -1,20 +1,22 @@
using System.Collections.Generic; using skydiveLogs_api.Domain;
using System.Collections.Generic;
using skydiveLogs_api.Domain;
namespace skydiveLogs_api.DomainBusiness.Interfaces namespace skydiveLogs_api.DomainBusiness.Interfaces
{ {
public interface IAircraftService public interface IAircraftService
{ {
IEnumerable<Aircraft> GetAllAircrafts(); #region Public Methods
Aircraft GetAircraftById(int id);
void AddNewAircraft(Aircraft aircraft); void AddNewAircraft(Aircraft aircraft);
void DeleteAircraftById(int id);
Aircraft GetAircraftById(int id);
IEnumerable<Aircraft> GetAllAircrafts();
void UpdateAircraft(int id, Aircraft aircraft); void UpdateAircraft(int id, Aircraft aircraft);
void DeleteAircraftById(int id); #endregion Public Methods
} }
} }

View File

@@ -4,6 +4,10 @@ namespace skydiveLogs_api.DomainBusiness.Interfaces
{ {
public interface IIdentityService public interface IIdentityService
{ {
#region Public Properties
User ConnectedUser { get; } User ConnectedUser { get; }
#endregion Public Properties
} }
} }

View File

@@ -2,6 +2,10 @@
{ {
public interface IInitDbService public interface IInitDbService
{ {
#region Public Methods
public void GenerateDb(); public void GenerateDb();
#endregion Public Methods
} }
} }

View File

@@ -1,6 +1,5 @@
using System.Collections.Generic; using skydiveLogs_api.Domain;
using System.Collections.Generic;
using skydiveLogs_api.Domain;
namespace skydiveLogs_api.DomainBusiness.Interfaces namespace skydiveLogs_api.DomainBusiness.Interfaces
{ {

View File

@@ -1,20 +1,22 @@
using System.Collections.Generic; using skydiveLogs_api.Domain;
using System.Collections.Generic;
using skydiveLogs_api.Domain;
namespace skydiveLogs_api.DomainBusiness.Interfaces namespace skydiveLogs_api.DomainBusiness.Interfaces
{ {
public interface IJumpTypeService public interface IJumpTypeService
{ {
#region Public Methods
void AddNewJumpType(JumpType value);
void DeleteJumpTypeById(int id);
IEnumerable<JumpType> GetAllJumpTypes(); IEnumerable<JumpType> GetAllJumpTypes();
JumpType GetJumpTypeById(int id); JumpType GetJumpTypeById(int id);
void AddNewJumpType(JumpType value);
void UpdateJumpType(int id, JumpType value); void UpdateJumpType(int id, JumpType value);
void DeleteJumpTypeById(int id); #endregion Public Methods
} }
} }

View File

@@ -1,6 +1,5 @@
using System.Collections.Generic; using skydiveLogs_api.Domain;
using System.Collections.Generic;
using skydiveLogs_api.Domain;
namespace skydiveLogs_api.DomainBusiness.Interfaces namespace skydiveLogs_api.DomainBusiness.Interfaces
{ {

View File

@@ -4,10 +4,14 @@ namespace skydiveLogs_api.DomainBusiness.Interfaces
{ {
public interface IUserService public interface IUserService
{ {
User GetByLogin(string login, string password); #region Public Methods
bool AddNewUser(User user, bool isAdmin = false);
User GetById(int userId); User GetById(int userId);
bool AddNewUser(User user, bool isAdmin = false); User GetByLogin(string login, string password);
#endregion Public Methods
} }
} }

View File

@@ -1,7 +1,6 @@
using skydiveLogs_api.Domain; using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainBusiness.Interfaces; using skydiveLogs_api.DomainBusiness.Interfaces;
using skydiveLogs_api.DomainService.Repositories; using skydiveLogs_api.DomainService.Repositories;
using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace skydiveLogs_api.DomainBusiness namespace skydiveLogs_api.DomainBusiness

View File

@@ -1,6 +1,5 @@
using skydiveLogs_api.Domain; using skydiveLogs_api.Domain;
namespace skydiveLogs_api.DomainService.Repositories namespace skydiveLogs_api.DomainService.Repositories
{ {
public interface IAircraftRepository : IRepository<Aircraft> public interface IAircraftRepository : IRepository<Aircraft>

View File

@@ -1,6 +1,5 @@
using skydiveLogs_api.Domain; using skydiveLogs_api.Domain;
namespace skydiveLogs_api.DomainService.Repositories namespace skydiveLogs_api.DomainService.Repositories
{ {
public interface IDropZoneRepository : IRepository<DropZone> public interface IDropZoneRepository : IRepository<DropZone>

View File

@@ -5,9 +5,12 @@ namespace skydiveLogs_api.DomainService.Repositories
{ {
public interface IFavoriteDropZoneRepository : IRepository<FavoriteDropZone> public interface IFavoriteDropZoneRepository : IRepository<FavoriteDropZone>
{ {
#region Public Methods
int Delete(int dropZoneId, int userId); int Delete(int dropZoneId, int userId);
IEnumerable<FavoriteDropZone> GetAll(User user); IEnumerable<FavoriteDropZone> GetAll(User user);
#endregion Public Methods
} }
} }

View File

@@ -5,6 +5,10 @@ namespace skydiveLogs_api.DomainService.Repositories
{ {
public interface IGearRepository : IRepository<Gear> public interface IGearRepository : IRepository<Gear>
{ {
#region Public Methods
IEnumerable<Gear> GetAll(User connectedUser); IEnumerable<Gear> GetAll(User connectedUser);
#endregion Public Methods
} }
} }

View File

@@ -5,8 +5,12 @@ namespace skydiveLogs_api.DomainService.Repositories
{ {
public interface IJumpRepository : IRepository<Jump> public interface IJumpRepository : IRepository<Jump>
{ {
IEnumerable<Jump> GetAll(User user); #region Public Methods
bool DeleteById(int id); bool DeleteById(int id);
IEnumerable<Jump> GetAll(User user);
#endregion Public Methods
} }
} }

View File

@@ -1,6 +1,5 @@
using skydiveLogs_api.Domain; using skydiveLogs_api.Domain;
namespace skydiveLogs_api.DomainService.Repositories namespace skydiveLogs_api.DomainService.Repositories
{ {
public interface IJumpTypeRepository : IRepository<JumpType> public interface IJumpTypeRepository : IRepository<JumpType>

View File

@@ -4,12 +4,16 @@ namespace skydiveLogs_api.DomainService.Repositories
{ {
public interface IRepository<T> public interface IRepository<T>
{ {
#region Public Methods
int Add(T newEntity);
IEnumerable<T> GetAll(); IEnumerable<T> GetAll();
T GetById(int id); T GetById(int id);
bool Update(T updated); bool Update(T updated);
int Add(T newEntity); #endregion Public Methods
} }
} }

View File

@@ -1,11 +1,14 @@
using System.Collections.Generic; using skydiveLogs_api.Domain;
using skydiveLogs_api.Domain; using System.Collections.Generic;
namespace skydiveLogs_api.DomainService.Repositories namespace skydiveLogs_api.DomainService.Repositories
{ {
public interface IUserImageRepository : IRepository<UserImage> public interface IUserImageRepository : IRepository<UserImage>
{ {
#region Public Methods
IEnumerable<UserImage> GetAll(User user); IEnumerable<UserImage> GetAll(User user);
#endregion Public Methods
} }
} }

View File

@@ -1,10 +1,13 @@
using skydiveLogs_api.Domain; using skydiveLogs_api.Domain;
namespace skydiveLogs_api.DomainService.Repositories namespace skydiveLogs_api.DomainService.Repositories
{ {
public interface IUserRepository : IRepository<User> public interface IUserRepository : IRepository<User>
{ {
#region Public Methods
User GetByLogin(string login, string password); User GetByLogin(string login, string password);
#endregion Public Methods
} }
} }

View File

@@ -1,37 +1,25 @@
using System.Collections.Generic; using LiteDB;
using System.Linq;
using LiteDB;
using skydiveLogs_api.Domain; using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories; using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces; using skydiveLogs_api.Infrastructure.Interfaces;
using System.Collections.Generic;
using System.Linq;
namespace skydiveLogs_api.Infrastructure namespace skydiveLogs_api.Infrastructure
{ {
public class AircraftRepository : IAircraftRepository public class AircraftRepository : IAircraftRepository
{ {
#region Public Constructors
public AircraftRepository(IDataProvider dataProvider) public AircraftRepository(IDataProvider dataProvider)
{ {
_dataProvider = dataProvider; _dataProvider = dataProvider;
_col = _dataProvider.CollOfAircraft; _col = _dataProvider.CollOfAircraft;
} }
public IEnumerable<Aircraft> GetAll() #endregion Public Constructors
{
return _col.FindAll().ToList();
}
public Aircraft GetById(int id) #region Public Methods
{
return _col.FindById(new BsonValue(id));
}
public bool Update(Aircraft aircraft)
{
return _col.Update(aircraft);
}
public int Add(Aircraft newAircraft) public int Add(Aircraft newAircraft)
{ {
@@ -50,8 +38,28 @@ namespace skydiveLogs_api.Infrastructure
return result; return result;
} }
private readonly IDataProvider _dataProvider; 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);
}
#endregion Public Methods
#region Private Fields
private readonly ILiteCollection<Aircraft> _col; private readonly ILiteCollection<Aircraft> _col;
private readonly IDataProvider _dataProvider;
#endregion Private Fields
} }
} }

View File

@@ -1,37 +1,25 @@
using System.Collections.Generic; using LiteDB;
using System.Linq;
using LiteDB;
using skydiveLogs_api.Domain; using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories; using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces; using skydiveLogs_api.Infrastructure.Interfaces;
using System.Collections.Generic;
using System.Linq;
namespace skydiveLogs_api.Infrastructure namespace skydiveLogs_api.Infrastructure
{ {
public class DropZoneRepository : IDropZoneRepository public class DropZoneRepository : IDropZoneRepository
{ {
#region Public Constructors
public DropZoneRepository(IDataProvider dataProvider) public DropZoneRepository(IDataProvider dataProvider)
{ {
_dataProvider = dataProvider; _dataProvider = dataProvider;
_col = _dataProvider.CollOfDropZone; _col = _dataProvider.CollOfDropZone;
} }
public IEnumerable<DropZone> GetAll() #endregion Public Constructors
{
return _col.FindAll().ToList();
}
public DropZone GetById(int id) #region Public Methods
{
return _col.FindById(new BsonValue(id));
}
public bool Update(DropZone updatedDz)
{
return _col.Update(updatedDz);
}
public int Add(DropZone newDz) public int Add(DropZone newDz)
{ {
@@ -50,8 +38,28 @@ namespace skydiveLogs_api.Infrastructure
return result; return result;
} }
private readonly IDataProvider _dataProvider; 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);
}
#endregion Public Methods
#region Private Fields
private readonly ILiteCollection<DropZone> _col; private readonly ILiteCollection<DropZone> _col;
private readonly IDataProvider _dataProvider;
#endregion Private Fields
} }
} }

View File

@@ -1,26 +1,24 @@
using System.Collections.Generic; using LiteDB;
using LiteDB;
using skydiveLogs_api.Domain; using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories; using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces; using skydiveLogs_api.Infrastructure.Interfaces;
using System.Collections.Generic;
namespace skydiveLogs_api.Infrastructure namespace skydiveLogs_api.Infrastructure
{ {
public class FavoriteDropZoneRepository : IFavoriteDropZoneRepository public class FavoriteDropZoneRepository : IFavoriteDropZoneRepository
{ {
#region Public Constructors
public FavoriteDropZoneRepository(IDataProvider dataProvider) public FavoriteDropZoneRepository(IDataProvider dataProvider)
{ {
_dataProvider = dataProvider; _dataProvider = dataProvider;
_col = _dataProvider.CollOfFavoriteDropZone; _col = _dataProvider.CollOfFavoriteDropZone;
} }
public int Delete(int dropZoneId, int userId) #endregion Public Constructors
{
return _col.DeleteMany(d => d.DropZone.Id == dropZoneId && d.User.Id == userId); #region Public Methods
}
public int Add(FavoriteDropZone favoriteToAdd) public int Add(FavoriteDropZone favoriteToAdd)
{ {
@@ -39,6 +37,11 @@ namespace skydiveLogs_api.Infrastructure
return result; return result;
} }
public int Delete(int dropZoneId, int userId)
{
return _col.DeleteMany(d => d.DropZone.Id == dropZoneId && d.User.Id == userId);
}
public IEnumerable<FavoriteDropZone> GetAll(User user) public IEnumerable<FavoriteDropZone> GetAll(User user)
{ {
return _col.Query() return _col.Query()
@@ -46,6 +49,11 @@ namespace skydiveLogs_api.Infrastructure
.ToList(); .ToList();
} }
public IEnumerable<FavoriteDropZone> GetAll()
{
throw new System.NotImplementedException();
}
public FavoriteDropZone GetById(int id) public FavoriteDropZone GetById(int id)
{ {
throw new System.NotImplementedException(); throw new System.NotImplementedException();
@@ -56,13 +64,13 @@ namespace skydiveLogs_api.Infrastructure
throw new System.NotImplementedException(); throw new System.NotImplementedException();
} }
public IEnumerable<FavoriteDropZone> GetAll() #endregion Public Methods
{
throw new System.NotImplementedException();
}
private readonly IDataProvider _dataProvider; #region Private Fields
private readonly ILiteCollection<FavoriteDropZone> _col; private readonly ILiteCollection<FavoriteDropZone> _col;
private readonly IDataProvider _dataProvider;
#endregion Private Fields
} }
} }

View File

@@ -1,22 +1,42 @@
using System.Collections.Generic; using LiteDB;
using LiteDB;
using skydiveLogs_api.Domain; using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories; using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces; using skydiveLogs_api.Infrastructure.Interfaces;
using System.Collections.Generic;
namespace skydiveLogs_api.Infrastructure namespace skydiveLogs_api.Infrastructure
{ {
public class GearRepository : IGearRepository public class GearRepository : IGearRepository
{ {
#region Public Constructors
public GearRepository(IDataProvider dataProvider) public GearRepository(IDataProvider dataProvider)
{ {
_dataProvider = dataProvider; _dataProvider = dataProvider;
_col = _dataProvider.CollOfGear; _col = _dataProvider.CollOfGear;
} }
#endregion Public Constructors
#region Public Methods
public int Add(Gear newGear)
{
int result;
try
{
var tmp = _col.Insert(newGear);
result = tmp.AsInt32;
}
catch
{
result = 0;
}
return result;
}
public IEnumerable<Gear> GetAll() public IEnumerable<Gear> GetAll()
{ {
throw new System.NotImplementedException(); throw new System.NotImplementedException();
@@ -40,25 +60,13 @@ namespace skydiveLogs_api.Infrastructure
return _col.Update(updatedGear); return _col.Update(updatedGear);
} }
public int Add(Gear newGear) #endregion Public Methods
{
int result;
try #region Private Fields
{
var tmp = _col.Insert(newGear);
result = tmp.AsInt32;
}
catch
{
result = 0;
}
return result;
}
private readonly IDataProvider _dataProvider;
private readonly ILiteCollection<Gear> _col; private readonly ILiteCollection<Gear> _col;
private readonly IDataProvider _dataProvider;
#endregion Private Fields
} }
} }

View File

@@ -2,29 +2,32 @@
using skydiveLogs_api.Domain; using skydiveLogs_api.Domain;
namespace skydiveLogs_api.Infrastructure.Interfaces namespace skydiveLogs_api.Infrastructure.Interfaces
{ {
public interface IDataProvider public interface IDataProvider
{ {
ILiteCollection<T> GetCollection<T>(); #region Public Methods
void Close(); void Close();
ILiteCollection<T> GetCollection<T>();
#endregion Public Methods
#region Public Properties
ILiteCollection<Aircraft> CollOfAircraft { get; } ILiteCollection<Aircraft> CollOfAircraft { get; }
ILiteCollection<DropZone> CollOfDropZone { get; } ILiteCollection<DropZone> CollOfDropZone { get; }
ILiteCollection<FavoriteDropZone> CollOfFavoriteDropZone { get; }
ILiteCollection<Gear> CollOfGear { get; } ILiteCollection<Gear> CollOfGear { get; }
ILiteCollection<JumpType> CollOfJumpType { get; } ILiteCollection<UserImage> CollOfImage { get; }
ILiteCollection<Jump> CollOfJump { get; } ILiteCollection<Jump> CollOfJump { get; }
ILiteCollection<JumpType> CollOfJumpType { get; }
ILiteCollection<User> CollOfUser { get; } ILiteCollection<User> CollOfUser { get; }
ILiteCollection<UserImage> CollOfImage { get; } #endregion Public Properties
ILiteCollection<FavoriteDropZone> CollOfFavoriteDropZone { get; }
} }
} }

View File

@@ -37,6 +37,11 @@ namespace skydiveLogs_api.Infrastructure
return result; return result;
} }
public bool DeleteById(int id)
{
return _col.Delete(new BsonValue(id));
}
public IEnumerable<Jump> GetAll(User user) public IEnumerable<Jump> GetAll(User user)
{ {
return _col.Include(x => x.Aircraft) return _col.Include(x => x.Aircraft)
@@ -63,11 +68,6 @@ namespace skydiveLogs_api.Infrastructure
return _col.Update(updatedJump); return _col.Update(updatedJump);
} }
public bool DeleteById(int id)
{
return _col.Delete(new BsonValue(id));
}
#endregion Public Methods #endregion Public Methods
#region Private Fields #region Private Fields

View File

@@ -1,37 +1,25 @@
using System.Collections.Generic; using LiteDB;
using System.Linq;
using LiteDB;
using skydiveLogs_api.Domain; using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories; using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces; using skydiveLogs_api.Infrastructure.Interfaces;
using System.Collections.Generic;
using System.Linq;
namespace skydiveLogs_api.Infrastructure namespace skydiveLogs_api.Infrastructure
{ {
public class JumpTypeRepository : IJumpTypeRepository public class JumpTypeRepository : IJumpTypeRepository
{ {
#region Public Constructors
public JumpTypeRepository(IDataProvider dataProvider) public JumpTypeRepository(IDataProvider dataProvider)
{ {
_dataProvider = dataProvider; _dataProvider = dataProvider;
_col = _dataProvider.CollOfJumpType; _col = _dataProvider.CollOfJumpType;
} }
public IEnumerable<JumpType> GetAll() #endregion Public Constructors
{
return _col.FindAll().ToList();
}
public JumpType GetById(int id) #region Public Methods
{
return _col.FindById(new BsonValue(id));
}
public bool Update(JumpType updatedJumpType)
{
return _col.Update(updatedJumpType);
}
public int Add(JumpType newJumpType) public int Add(JumpType newJumpType)
{ {
@@ -50,8 +38,28 @@ namespace skydiveLogs_api.Infrastructure
return result; return result;
} }
private readonly IDataProvider _dataProvider; 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);
}
#endregion Public Methods
#region Private Fields
private readonly ILiteCollection<JumpType> _col; private readonly ILiteCollection<JumpType> _col;
private readonly IDataProvider _dataProvider;
#endregion Private Fields
} }
} }

View File

@@ -3,11 +3,12 @@
using skydiveLogs_api.Domain; using skydiveLogs_api.Domain;
using skydiveLogs_api.Infrastructure.Interfaces; using skydiveLogs_api.Infrastructure.Interfaces;
namespace skydiveLogs_api.Infrastructure namespace skydiveLogs_api.Infrastructure
{ {
public class LiteDbProvider : IDataProvider public class LiteDbProvider : IDataProvider
{ {
#region Public Constructors
public LiteDbProvider(string connectionString) public LiteDbProvider(string connectionString)
{ {
_db = new LiteDatabase(connectionString); _db = new LiteDatabase(connectionString);
@@ -26,32 +27,39 @@ namespace skydiveLogs_api.Infrastructure
BsonMapper.Global.Entity<FavoriteDropZone>().DbRef(x => x.DropZone, "DropZone"); BsonMapper.Global.Entity<FavoriteDropZone>().DbRef(x => x.DropZone, "DropZone");
} }
public ILiteCollection<T> GetCollection<T>() #endregion Public Constructors
{
return _db.GetCollection<T>(); #region Public Methods
}
public void Close() public void Close()
{ {
_db.Dispose(); _db.Dispose();
} }
private readonly LiteDatabase _db; public ILiteCollection<T> GetCollection<T>()
{
return _db.GetCollection<T>();
}
#endregion Public Methods
#region Public Properties
public ILiteCollection<Aircraft> CollOfAircraft => _db.GetCollection<Aircraft>(); public ILiteCollection<Aircraft> CollOfAircraft => _db.GetCollection<Aircraft>();
public ILiteCollection<DropZone> CollOfDropZone => _db.GetCollection<DropZone>(); public ILiteCollection<DropZone> CollOfDropZone => _db.GetCollection<DropZone>();
public ILiteCollection<FavoriteDropZone> CollOfFavoriteDropZone => _db.GetCollection<FavoriteDropZone>();
public ILiteCollection<Gear> CollOfGear => _db.GetCollection<Gear>(); public ILiteCollection<Gear> CollOfGear => _db.GetCollection<Gear>();
public ILiteCollection<UserImage> CollOfImage => _db.GetCollection<UserImage>();
public ILiteCollection<JumpType> CollOfJumpType => _db.GetCollection<JumpType>();
public ILiteCollection<Jump> CollOfJump => _db.GetCollection<Jump>(); public ILiteCollection<Jump> CollOfJump => _db.GetCollection<Jump>();
public ILiteCollection<JumpType> CollOfJumpType => _db.GetCollection<JumpType>();
public ILiteCollection<User> CollOfUser => _db.GetCollection<User>(); public ILiteCollection<User> CollOfUser => _db.GetCollection<User>();
public ILiteCollection<UserImage> CollOfImage => _db.GetCollection<UserImage>(); #endregion Public Properties
public ILiteCollection<FavoriteDropZone> CollOfFavoriteDropZone => _db.GetCollection<FavoriteDropZone>(); #region Private Fields
private readonly LiteDatabase _db;
#endregion Private Fields
} }
} }

View File

@@ -1,22 +1,42 @@
using System.Collections.Generic; using LiteDB;
using LiteDB;
using skydiveLogs_api.Domain; using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories; using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces; using skydiveLogs_api.Infrastructure.Interfaces;
using System.Collections.Generic;
namespace skydiveLogs_api.Infrastructure namespace skydiveLogs_api.Infrastructure
{ {
public class UserImageRepository : IUserImageRepository public class UserImageRepository : IUserImageRepository
{ {
#region Public Constructors
public UserImageRepository(IDataProvider dataProvider) public UserImageRepository(IDataProvider dataProvider)
{ {
_dataProvider = dataProvider; _dataProvider = dataProvider;
_col = _dataProvider.CollOfImage; _col = _dataProvider.CollOfImage;
} }
#endregion Public Constructors
#region Public Methods
public int Add(UserImage newImage)
{
int result;
try
{
var tmp = _col.Insert(newImage);
result = tmp.AsInt32;
}
catch
{
result = 0;
}
return result;
}
public IEnumerable<UserImage> GetAll() public IEnumerable<UserImage> GetAll()
{ {
throw new System.NotImplementedException(); throw new System.NotImplementedException();
@@ -40,25 +60,13 @@ namespace skydiveLogs_api.Infrastructure
return _col.Update(image); return _col.Update(image);
} }
public int Add(UserImage newImage) #endregion Public Methods
{
int result;
try #region Private Fields
{
var tmp = _col.Insert(newImage);
result = tmp.AsInt32;
}
catch
{
result = 0;
}
return result;
}
private readonly IDataProvider _dataProvider;
private readonly ILiteCollection<UserImage> _col; private readonly ILiteCollection<UserImage> _col;
private readonly IDataProvider _dataProvider;
#endregion Private Fields
} }
} }

View File

@@ -1,27 +1,25 @@
using System; using LiteDB;
using System.Collections.Generic;
using LiteDB;
using skydiveLogs_api.Domain; using skydiveLogs_api.Domain;
using skydiveLogs_api.DomainService.Repositories; using skydiveLogs_api.DomainService.Repositories;
using skydiveLogs_api.Infrastructure.Interfaces; using skydiveLogs_api.Infrastructure.Interfaces;
using System;
using System.Collections.Generic;
namespace skydiveLogs_api.Infrastructure namespace skydiveLogs_api.Infrastructure
{ {
public class UserRepository : IUserRepository public class UserRepository : IUserRepository
{ {
#region Public Constructors
public UserRepository(IDataProvider dataProvider) public UserRepository(IDataProvider dataProvider)
{ {
_dataProvider = dataProvider; _dataProvider = dataProvider;
_col = _dataProvider.CollOfUser; _col = _dataProvider.CollOfUser;
} }
public User GetByLogin(string login, string password) #endregion Public Constructors
{
return _col.FindOne(u => u.Login == login && u.Password == password); #region Public Methods
}
public int Add(User newUser) public int Add(User newUser)
{ {
@@ -50,13 +48,23 @@ namespace skydiveLogs_api.Infrastructure
return _col.FindById(new BsonValue(id)); return _col.FindById(new BsonValue(id));
} }
public User GetByLogin(string login, string password)
{
return _col.FindOne(u => u.Login == login && u.Password == password);
}
public bool Update(User updated) public bool Update(User updated)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
private readonly IDataProvider _dataProvider; #endregion Public Methods
#region Private Fields
private readonly ILiteCollection<User> _col; private readonly ILiteCollection<User> _col;
private readonly IDataProvider _dataProvider;
#endregion Private Fields
} }
} }

View File

@@ -40,14 +40,6 @@ namespace skydiveLogs_api.Controllers
return _mapper.Map<IEnumerable<AircraftResp>>(result); return _mapper.Map<IEnumerable<AircraftResp>>(result);
} }
[HttpGet("GetSimple")]
[EnableCors]
public IEnumerable<AircraftSimpleResp> GetSimple()
{
var result = _aircraftService.GetAllAircrafts();
return _mapper.Map<IEnumerable<AircraftSimpleResp>>(result);
}
// GET: api/Aircraft/5 // GET: api/Aircraft/5
[HttpGet("{id}")] [HttpGet("{id}")]
[EnableCors] [EnableCors]
@@ -57,6 +49,14 @@ namespace skydiveLogs_api.Controllers
return _mapper.Map<AircraftResp>(result); return _mapper.Map<AircraftResp>(result);
} }
[HttpGet("GetSimple")]
[EnableCors]
public IEnumerable<AircraftSimpleResp> GetSimple()
{
var result = _aircraftService.GetAllAircrafts();
return _mapper.Map<IEnumerable<AircraftSimpleResp>>(result);
}
// POST: api/Aircraft // POST: api/Aircraft
[HttpPost] [HttpPost]
[EnableCors] [EnableCors]

View File

@@ -49,15 +49,6 @@ namespace skydiveLogs_api.Controllers
return _mapper.Map<IEnumerable<DropZoneResp>>(result); return _mapper.Map<IEnumerable<DropZoneResp>>(result);
} }
[HttpGet("GetSimple")]
[EnableCors]
public IEnumerable<DropZoneSimpleResp> GetSimple()
{
var result = _dropZoneService.GetAllDzs();
return _mapper.Map<IEnumerable<DropZoneSimpleResp>>(result);
}
// GET: api/DropZone/5 // GET: api/DropZone/5
[HttpGet("{id}")] [HttpGet("{id}")]
[EnableCors] [EnableCors]
@@ -68,6 +59,15 @@ namespace skydiveLogs_api.Controllers
return _mapper.Map<DropZoneResp>(result); return _mapper.Map<DropZoneResp>(result);
} }
[HttpGet("GetSimple")]
[EnableCors]
public IEnumerable<DropZoneSimpleResp> GetSimple()
{
var result = _dropZoneService.GetAllDzs();
return _mapper.Map<IEnumerable<DropZoneSimpleResp>>(result);
}
// POST: api/DropZone // POST: api/DropZone
[HttpPost] [HttpPost]
[EnableCors] [EnableCors]