Add a controler for "User" (add and authenticate)

This commit is contained in:
Sébastien André
2020-03-12 12:24:51 +01:00
parent 8a29fd7de9
commit 32a27b6d26
23 changed files with 225 additions and 34 deletions

View File

@@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Linq;
using LiteDB;
using skydiveLogs_api.Data.Interface;
using skydiveLogs_api.Model;
namespace skydiveLogs_api.Data
{
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)
{
throw new NotImplementedException();
}
public bool Update(User updated)
{
throw new NotImplementedException();
}
private readonly IDataProvider _dataProvider;
private readonly ILiteCollection<User> _col;
}
}