Publish from private repository

This commit is contained in:
Gitea Actions
2026-08-01 11:53:53 +00:00
commit ac7c7bc8ea
694 changed files with 69367 additions and 0 deletions
@@ -0,0 +1,17 @@
namespace MyOffice.Data.Repositories.Item;
using MyOffice.Data.Models.Items;
public interface IItemCategoryRepository
{
List<ItemCategory> GetAll(Guid userId);
Task<List<ItemCategory>> GetAllAsync(Guid userId, CancellationToken cancellationToken = default);
bool Add(ItemCategory accountCategory);
Task<bool> AddAsync(ItemCategory accountCategory, CancellationToken cancellationToken = default);
ItemCategory? Get(Guid userId, Guid id);
Task<ItemCategory?> GetAsync(Guid userId, Guid id, CancellationToken cancellationToken = default);
bool Update(ItemCategory accountCategory);
Task<bool> UpdateAsync(ItemCategory accountCategory, CancellationToken cancellationToken = default);
bool Remove(ItemCategory accountCategory);
Task<bool> RemoveAsync(ItemCategory accountCategory, CancellationToken cancellationToken = default);
}
@@ -0,0 +1,14 @@
namespace MyOffice.Data.Repositories.Item;
using MyOffice.Data.Models.Items;
public interface IItemGlobalRepository
{
ItemGlobal? Get(Guid id);
ItemGlobal? GetByName(string name);
Task<ItemGlobal?> GetByNameAsync(string name, CancellationToken cancellationToken = default);
bool Add(ItemGlobal itemGlobal);
Task<bool> AddAsync(ItemGlobal itemGlobal, CancellationToken cancellationToken = default);
List<ItemGlobal> GetAvailableToUser(Guid userId);
Task<List<ItemGlobal>> GetAvailableToUserAsync(Guid userId, CancellationToken cancellationToken = default);
}
@@ -0,0 +1,19 @@
namespace MyOffice.Data.Repositories.Item;
using MyOffice.Data.Models.Items;
public interface IItemRepository
{
List<Item> GetAll(Guid userId);
Task<List<Item>> GetAllAsync(Guid userId, CancellationToken cancellationToken = default);
List<Item> GetByCategory(Guid userId, Guid categoryId);
Task<List<Item>> GetByCategoryAsync(Guid userId, Guid categoryId, CancellationToken cancellationToken = default);
Item? GetByGlobal(Guid userId, Guid globalItemId);
Task<Item?> GetByGlobalAsync(Guid userId, Guid globalItemId, CancellationToken cancellationToken = default);
bool Add(Item item);
Task<bool> AddAsync(Item item, CancellationToken cancellationToken = default);
bool Update(Item item);
Task<bool> UpdateAsync(Item item, CancellationToken cancellationToken = default);
List<Item> Find(Guid userId, string term, int limit);
Task<List<Item>> FindAsync(Guid userId, string term, int limit, CancellationToken cancellationToken = default);
}
@@ -0,0 +1,72 @@
namespace MyOffice.Data.Repositories.Item;
using Microsoft.EntityFrameworkCore;
using MyOffice.Data.Models.Items;
using MyOffice.DbContext;
public class ItemCategoryRepository : AppRepository<ItemCategory>, IItemCategoryRepository
{
public ItemCategoryRepository(AppDbContext context) : base(context)
{
}
public List<ItemCategory> GetAll(Guid userId)
{
return _context.ItemCategories
.Include(x => x.Items)
.Where(x => x.UserId == userId)
.ToList();
}
public async Task<List<ItemCategory>> GetAllAsync(Guid userId, CancellationToken cancellationToken = default)
{
return await _context.ItemCategories
.Include(x => x.Items)
.Where(x => x.UserId == userId)
.ToListAsync(cancellationToken);
}
public bool Add(ItemCategory itemCategory)
{
return AddBase(itemCategory) > 0;
}
public async Task<bool> AddAsync(ItemCategory itemCategory, CancellationToken cancellationToken = default)
{
return await AddBaseAsync(itemCategory, cancellationToken) > 0;
}
public ItemCategory? Get(Guid userId, Guid id)
{
return _context.ItemCategories
.Include(x => x.Items)
.FirstOrDefault(x => x.Id == id && x.UserId == userId);
}
public async Task<ItemCategory?> GetAsync(Guid userId, Guid id, CancellationToken cancellationToken = default)
{
return await _context.ItemCategories
.Include(x => x.Items)
.FirstOrDefaultAsync(x => x.Id == id && x.UserId == userId, cancellationToken);
}
public bool Update(ItemCategory itemCategory)
{
return UpdateBase(itemCategory) > 0;
}
public async Task<bool> UpdateAsync(ItemCategory itemCategory, CancellationToken cancellationToken = default)
{
return await UpdateBaseAsync(itemCategory, cancellationToken) > 0;
}
public bool Remove(ItemCategory itemCategory)
{
return RemoveBase(itemCategory) > 0;
}
public async Task<bool> RemoveAsync(ItemCategory itemCategory, CancellationToken cancellationToken = default)
{
return await RemoveBaseAsync(itemCategory, cancellationToken) > 0;
}
}
@@ -0,0 +1,69 @@
namespace MyOffice.Data.Repositories.Item;
using Microsoft.EntityFrameworkCore;
using MyOffice.Data.Models.Items;
using MyOffice.DbContext;
public class ItemGlobalRepository : AppRepository<ItemGlobal>, IItemGlobalRepository
{
public ItemGlobalRepository(AppDbContext context) : base(context)
{
}
public ItemGlobal? Get(Guid id)
{
return _context.ItemGlobals.FirstOrDefault(x => x.Id == id);
}
public ItemGlobal? GetByName(string name)
{
return _context.ItemGlobals.FirstOrDefault(x => x.Name == name);
}
public Task<ItemGlobal?> GetByNameAsync(string name, CancellationToken cancellationToken = default)
{
return _context.ItemGlobals.FirstOrDefaultAsync(x => x.Name == name, cancellationToken);
}
public bool Add(ItemGlobal itemGlobal)
{
return AddBase(itemGlobal) > 0;
}
public async Task<bool> AddAsync(ItemGlobal itemGlobal, CancellationToken cancellationToken = default)
{
return await AddBaseAsync(itemGlobal, cancellationToken) > 0;
}
public List<ItemGlobal> GetAvailableToUser(Guid userId)
{
return _context.Motions
.Include(x => x.Item)
.ThenInclude(x => x.ItemGlobal)
.ThenInclude(x => x.Items)
.ThenInclude(x => x.Category)
.Where(x => x.Account.AccessRights!.Any(a => a.UserId == userId))
.Where(x => x.Item.ItemGlobal.Items.All(g => g.Category!.UserId != userId))
.Select(x => x.Item.ItemGlobal)
.GroupBy(x => x.Id)
.Select(x => x.First())
.ToList();
}
public async Task<List<ItemGlobal>> GetAvailableToUserAsync(
Guid userId,
CancellationToken cancellationToken = default)
{
return await _context.Motions
.Include(x => x.Item)
.ThenInclude(x => x.ItemGlobal)
.ThenInclude(x => x.Items)
.ThenInclude(x => x.Category)
.Where(x => x.Account.AccessRights!.Any(a => a.UserId == userId))
.Where(x => x.Item.ItemGlobal.Items.All(g => g.Category!.UserId != userId))
.Select(x => x.Item.ItemGlobal)
.GroupBy(x => x.Id)
.Select(x => x.First())
.ToListAsync(cancellationToken);
}
}
@@ -0,0 +1,121 @@
namespace MyOffice.Data.Repositories.Item;
using Microsoft.EntityFrameworkCore;
using MyOffice.Data.Models.Items;
using MyOffice.DbContext;
public class ItemRepository : AppRepository<Item>, IItemRepository
{
public ItemRepository(AppDbContext context) : base(context)
{
}
public List<Item> GetAll(Guid userId)
{
return _context.Items
.Include(x => x.Motions)
.Include(x => x.Category)
.Include(x => x.ItemGlobal)
.Where(x => x.Category!.UserId == userId)
.ToList();
}
public async Task<List<Item>> GetAllAsync(Guid userId, CancellationToken cancellationToken = default)
{
return await _context.Items
.Include(x => x.Motions)
.Include(x => x.Category)
.Include(x => x.ItemGlobal)
.Where(x => x.Category!.UserId == userId)
.ToListAsync(cancellationToken);
}
public List<Item> GetByCategory(Guid userId, Guid categoryId)
{
return _context.Items
.Include(x => x.Motions)
.Include(x => x.Category)
.Include(x => x.ItemGlobal)
.Where(x => x.Category!.UserId == userId && x.CategoryId == categoryId)
.ToList();
}
public async Task<List<Item>> GetByCategoryAsync(
Guid userId,
Guid categoryId,
CancellationToken cancellationToken = default)
{
return await _context.Items
.Include(x => x.Motions)
.Include(x => x.Category)
.Include(x => x.ItemGlobal)
.Where(x => x.Category!.UserId == userId && x.CategoryId == categoryId)
.ToListAsync(cancellationToken);
}
public Item? GetByGlobal(Guid userId, Guid globalItemId)
{
return _context.Items
.Include(x => x.Motions)
.Include(x => x.Category)
.Include(x => x.ItemGlobal)
.FirstOrDefault(x => x.Category!.UserId == userId && x.ItemGlobalId == globalItemId);
}
public Task<Item?> GetByGlobalAsync(Guid userId, Guid globalItemId, CancellationToken cancellationToken = default)
{
return _context.Items
.Include(x => x.Motions)
.Include(x => x.Category)
.Include(x => x.ItemGlobal)
.FirstOrDefaultAsync(
x => x.Category!.UserId == userId && x.ItemGlobalId == globalItemId,
cancellationToken);
}
public bool Update(Item item)
{
return base.UpdateBase(item) > 0;
}
public async Task<bool> UpdateAsync(Item item, CancellationToken cancellationToken = default)
{
return await UpdateBaseAsync(item, cancellationToken) > 0;
}
public bool Add(Item item)
{
return base.AddBase(item) > 0;
}
public async Task<bool> AddAsync(Item item, CancellationToken cancellationToken = default)
{
return await AddBaseAsync(item, cancellationToken) > 0;
}
public List<Item> Find(Guid userId, string term, int limit)
{
return _context
.Items
.Include(x => x.ItemGlobal)
.Where(x => x.Category!.UserId == userId && x.ItemGlobal.Name.ToLower().Contains(term.ToLower()))
.OrderByDescending(x => x!.Motions!.Count())
.Take(limit)
.ToList();
}
public async Task<List<Item>> FindAsync(
Guid userId,
string term,
int limit,
CancellationToken cancellationToken = default)
{
return await _context
.Items
.Include(x => x.ItemGlobal)
.Where(x => x.Category!.UserId == userId && x.ItemGlobal.Name.ToLower().Contains(term.ToLower()))
.OrderByDescending(x => x!.Motions!.Count())
.Take(limit)
.ToListAsync(cancellationToken);
}
}