@ -1,4 +1,4 @@
using DbContextLib ;
using DbContextLib ;
using Model.DTO ;
using System ;
using System.Collections.Generic ;
@ -13,28 +13,27 @@ using ModelToEntity;
namespace Services
{
public class UserDataService : I DataService
public class UserDataService : I User DataService< UserDTO ? >
{
private UserDbContext DbContext { get ; set ; }
private readonly IDataServiceEF dataServiceEF ;
public UserDataService ( IDataServiceEF dataServiceEF )
private readonly IUserDataService < User > dataServiceEF ;
public UserDataService ( IUserDataService < User > dataServiceEF )
{
this . dataServiceEF = dataServiceEF ;
}
public async Task < UserDTO > GetUserById ( int id )
public async Task < UserDTO ? > GetUserById ( int id )
{
var user = await dataServiceEF . GetUserById ( id ) ;
return user . FromModelToDTO ( ) ;
}
public async Task < UserDTO > GetUserByUsername ( string username )
public async Task < UserDTO ? > GetUserByUsername ( string username )
{
var user = await dataServiceEF . GetUserByUsername ( username ) ;
return user . FromModelToDTO ( ) ;
}
public async Task < IEnumerable < UserDTO >> GetUsers ( int page , int number )
public async Task < IEnumerable < UserDTO ? >> GetUsers ( int page , int number )
{
var users = await dataServiceEF . GetUsers ( page , number ) ;
return users . Select ( u = > u . FromModelToDTO ( ) ) ;
@ -46,74 +45,39 @@ namespace Services
return respons ;
}
public async Task < UserDTO > UpdateUser ( int id , UserDTO user )
public async Task < UserDTO ? > UpdateUser ( int id , UserDTO user )
{
var updatingUser = await dataServiceEF . UpdateUser ( id , user ) ;
return updatingUser . FromModelToDTO ( ) ;
}
public async Task < UserDTO > CreateUser ( string username , string password , string email , bool isAdmin )
public async Task < UserDTO ? > CreateUser ( string username , string password , string email , bool isAdmin )
{
var newUserEntity = await dataServiceEF . CreateUser ( username , password , email , isAdmin ) ;
return newUserEntity . FromModelToDTO ( ) ;
}
public IEnumerable < InquiryDTO > GetInquiries ( int page , int number )
public async Task < T ? > AddItem < T > ( T ? item ) where T : class
{
throw new NotImplementedException ( ) ;
}
public InquiryDTO GetInquiryById ( int id )
{
throw new NotImplementedException ( ) ;
}
public InquiryDTO GetInquiryByTitle ( string title )
{
throw new NotImplementedException ( ) ;
}
public UserDTO CreateInquiry ( string title , string description , bool isUser , InquiryTableEntity database , SolutionEntity inquiryTable )
{
throw new NotImplementedException ( ) ;
var newItem = dataServiceEF . AddItem ( item ) ;
return await newItem ;
}
public bool DeleteInquiry ( int id )
public Task < bool > DeleteItem < T > ( int id ) where T : class
{
throw new NotImplementedException ( ) ;
var succes = dataServiceEF . DeleteItem < T > ( id ) ;
return succes ;
}
public InquiryDTO UpdateInquiry ( int id , InquiryDTO inquiry )
public Task < T > UpdateItem < T , TDto > ( int? id , TDto ? newItem ) where T : class where TDto : class
{
throw new NotImplementedException ( ) ;
}
public IEnumerable < InquiryDTO > GetLessons ( int page , int number )
{
throw new NotImplementedException ( ) ;
var item = dataServiceEF . UpdateItem < T , TDto > ( id , newItem ) ;
return item ;
}
public InquiryDTO GetLessonById ( int id )
public Task < IEnumerable < T ? > > GetItems < T > ( int index , int count , string? orderingPropertyName = null , object? valueProperty = null ) where T : class
{
throw new NotImplementedException ( ) ;
}
public InquiryDTO GetLessonByTitle ( string title )
{
throw new NotImplementedException ( ) ;
}
public bool DeleteLesson ( int id )
{
throw new NotImplementedException ( ) ;
}
public InquiryDTO UpdateLesson ( int id , LessonDTO lesson )
{
throw new NotImplementedException ( ) ;
}
public UserDTO CreateLesson ( string title , string lastPublisher , DateOnly lastEdit )
{
throw new NotImplementedException ( ) ;
var items = dataServiceEF . GetItems < T > ( index , count , orderingPropertyName , valueProperty ) ;
return items ;
}
public Task < IEnumerable < ParagraphDTO > > GetParagraphs ( int page , int number )