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
{
///
/// Service der die Verwaltung von DogOwnern ermöglicht
///
public class DogOwnerService : IDogOwnerService
{
private readonly ICommunicationService _communicationService;
private readonly ILocationService _locationService;
///
/// Erstellt eine Instanz
///
/// Instanz eines ICommunicationService
/// Instanz eines ILocationService
public DogOwnerService(ICommunicationService communicationService, ILocationService locationService)
{
_communicationService = communicationService;
_locationService = locationService;
}
///
/// Gibt Detailinfos zu einem DogOwner zurück
///
/// Id des Dogowners
/// Aktuelles Accesstoken
/// CancellationToken
/// CommunicationResult
public async Task> GetDogOwnerAsync(string dogOwnerId, string accessToken, CancellationToken token)
{
var result = new CommunicationResult() { 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;
}
}
}