testapi
This commit is contained in:
1 parent
2db9525570
commit
5aca82244e
21 files changed
+545
-126
No files matched your search
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using uWine.Core.Domain.Entities;
|
||||
using uWine.Core.Domain.Repositories;
|
||||
|
||||
namespace uWine.Core.Infrastructure.Services
|
||||
{
|
||||
public class UserService
|
||||
{
|
||||
public IUserRepository _userRepository;
|
||||
readonly OwnerService _ownerService;
|
||||
readonly IOwnerRepository _ownerRepository;
|
||||
|
||||
|
||||
public UserService(
|
||||
IUserRepository userRepository, OwnerService ownerService, IOwnerRepository ownerRepository)
|
||||
{
|
||||
_userRepository = userRepository;
|
||||
_ownerService = ownerService;
|
||||
_ownerRepository = ownerRepository;
|
||||
}
|
||||
|
||||
public User Process(int userId)
|
||||
{
|
||||
var user = _userRepository.UserById(userId);
|
||||
if (user == null)
|
||||
throw new ArgumentException($"User with ID {userId} not found.");
|
||||
|
||||
var owners = _ownerRepository.FromUser(userId)
|
||||
?.Select(owner => _ownerService.FillData(owner))
|
||||
.ToList();
|
||||
|
||||
user.Owners = owners ?? new List<Owner>();
|
||||
return user;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user