62 lines
1.3 KiB
C#
62 lines
1.3 KiB
C#
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;
|
|
}
|
|
}
|