Добавьте файлы проекта.

This commit is contained in:
2024-07-10 20:19:26 +07:00
parent 212a005438
commit e3c69229ad
74 changed files with 5674 additions and 0 deletions

View File

@ -0,0 +1,59 @@
using Yuna.Website.Server.Model;
using Yuna.Website.Server.Storage.Repositories.Prop;
namespace Yuna.Website.Server.Services.DeviceSkillService
{
public class PropService : IPropService
{
private readonly IPropRepository _propRepository;
public PropService(IPropRepository propRepository)
{
_propRepository = propRepository;
}
public async Task<Prop?> Create(Prop prop)
{
var existingProp = await _propRepository.GetByPropName(prop.Name);
if (existingProp is not null) return null;
var result = await _propRepository.Create(prop);
return result;
}
public async Task<Prop?> Delete(long id)
{
var prop = await _propRepository.GetById(id);
if (prop is null) return null;
var result = await _propRepository.Delete(id);
return result;
}
public async Task<Prop?> GetById(long id)
{
var result = await _propRepository.GetById(id);
return result;
}
public async Task<IReadOnlyList<Prop>?> GetByIds(long[] ids)
{
if (ids.Count() == 0) return [];
var props = await _propRepository.GetByIds(ids);
return props;
}
public async Task<Prop?> GetByPropName(string name)
{
var result = await _propRepository.GetByPropName(name);
return result;
}
public async Task<IReadOnlyList<Prop>> GetList()
{
var result = await _propRepository.GetList();
return result ?? [];
}
}
}