61 lines
2.2 KiB
C#
61 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using gehGassi.Dto;
|
|
using gehGassiApp.Core.Interfaces;
|
|
using gehGassiApp.Core.Resources;
|
|
using gehGassiApp.Domain.Lookup;
|
|
|
|
namespace gehGassiApp.Core.Services
|
|
{
|
|
/// <summary>
|
|
/// Service der die Verwaltung von DogOwnern ermöglicht
|
|
/// </summary>
|
|
public class DogOwnerService : IDogOwnerService
|
|
{
|
|
private readonly ICommunicationService _communicationService;
|
|
private readonly ILocationService _locationService;
|
|
|
|
/// <summary>
|
|
/// Erstellt eine Instanz
|
|
/// </summary>
|
|
/// <param name="communicationService">Instanz eines ICommunicationService</param>
|
|
/// <param name="locationService">Instanz eines ILocationService</param>
|
|
public DogOwnerService(ICommunicationService communicationService, ILocationService locationService)
|
|
{
|
|
_communicationService = communicationService;
|
|
_locationService = locationService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gibt Detailinfos zu einem DogOwner zurück
|
|
/// </summary>
|
|
/// <param name="dogOwnerId">Id des Dogowners</param>
|
|
/// <param name="accessToken">Aktuelles Accesstoken</param>
|
|
/// <param name="token">CancellationToken</param>
|
|
/// <returns>CommunicationResult</returns>
|
|
public async Task<CommunicationResult<DogOwnerInfo>> GetDogOwnerAsync(string dogOwnerId, string accessToken, CancellationToken token)
|
|
{
|
|
var result = new CommunicationResult<DogOwnerInfo>() { Value = new DogOwnerInfo() };
|
|
|
|
var isConnected = await _communicationService.IsConnected();
|
|
if (isConnected)
|
|
{
|
|
var dogOwnerResult = await _communicationService.GetDogOwnerAsync(dogOwnerId, accessToken, token);
|
|
if (dogOwnerResult.Success)
|
|
return dogOwnerResult;
|
|
}
|
|
else
|
|
{
|
|
result.Success = false;
|
|
result.ErrorCode = CommunicationErrors.ServerNoConnection;
|
|
result.ErrorMessage = Errors.Server_NoConnection;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
}
|