|
|
|
@ -3,6 +3,7 @@ using Entities;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using Model.OrderCriteria;
|
|
|
|
|
using Shared;
|
|
|
|
|
using Shared.ModelToEntities;
|
|
|
|
|
|
|
|
|
|
namespace DbDataManager.Service;
|
|
|
|
|
|
|
|
|
@ -86,4 +87,40 @@ public class LessonDataService : ILessonService<LessonEntity>
|
|
|
|
|
DbContext.SaveChangesAsync();
|
|
|
|
|
return newLessonEntity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<LessonEntity?> AddItem(LessonEntity? item)
|
|
|
|
|
{
|
|
|
|
|
using (var context = DbContext = new UserDbContext())
|
|
|
|
|
{
|
|
|
|
|
var lesson = await context.CreateItemAsync<LessonEntity>(item);
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<bool> DeleteItem(int id)
|
|
|
|
|
{
|
|
|
|
|
using (var context = DbContext = new UserDbContext())
|
|
|
|
|
{
|
|
|
|
|
var succes = await context.DeleteItemAsync<LessonEntity>(id);
|
|
|
|
|
return succes;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<LessonEntity> UpdateItem<TDto>(int? id, TDto? newItem) where TDto : class
|
|
|
|
|
{
|
|
|
|
|
using (var context = DbContext = new UserDbContext())
|
|
|
|
|
{
|
|
|
|
|
var lesson = await context.UpdateItemAsync<LessonEntity, TDto>(id, newItem);
|
|
|
|
|
return lesson;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<IEnumerable<LessonEntity>> GetItems(int page, int count, object? orderCriteria = null, string? filter = null, object? valueFilter = null)
|
|
|
|
|
{
|
|
|
|
|
using (var context = DbContext = new UserDbContext())
|
|
|
|
|
{
|
|
|
|
|
var lessons = await context.GetItemsWithFilter<LessonEntity>(page, count, orderCriteria, filter, valueFilter);
|
|
|
|
|
return lessons;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|