﻿using pdt.Services;
using Quest.Common.Messages.GIS;
using System;
using System.Threading.Tasks;

namespace pdt.Managers
{
    public class OperationalMapManager
    {
        private readonly ServiceManager _serviceManager;

        private const int _MAP_ARTEFACTS_PAYLOAD_COUNT = 100;

        private int mapArtefactsSkipValue;

        public OperationalMapManager(ServiceManager serviceManager)
        {
            _serviceManager = serviceManager;
        }

        //public MapItemsRequest MapArtefactOptions { get; set; }

        public async Task<MapItemsResponse> GetMapItemsAsync(MapItemsRequest mapArtefactOptions)
        {
            mapArtefactOptions.Skip = mapArtefactsSkipValue;
            mapArtefactOptions.Take = _MAP_ARTEFACTS_PAYLOAD_COUNT;

            try
            {
                var ret =  await _serviceManager.GetMapItemsAsync(mapArtefactOptions);

                mapArtefactsSkipValue += _MAP_ARTEFACTS_PAYLOAD_COUNT;

                return ret;
            }
            catch (Exception e)
            {
                return new MapItemsResponse() { Success = false, Message = e.Message };
            }
        }




    }
}
