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 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 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 GetById(long id) { var result = await _propRepository.GetById(id); return result; } public async Task?> GetByIds(long[] ids) { if (ids.Count() == 0) return []; var props = await _propRepository.GetByIds(ids); return props; } public async Task GetByPropName(string name) { var result = await _propRepository.GetByPropName(name); return result; } public async Task> GetList() { var result = await _propRepository.GetList(); return result ?? []; } } }