namespace Pluto.Api {
    using System.Collections;
    using System.Collections.Generic;
    using System.Linq;
    using PlutoServer.MSL;
    using System;
    using PlutoServer.MSL.Connectors;

    [RemObjects.SDK.Server.ClassFactories.StandardClassFactory()]
    [RemObjects.SDK.Server.Service(Name = "Schedule", InvokerClass = typeof(Schedule_Invoker), ActivatorClass = typeof(Schedule_Activator))]
    public class Schedule : RemObjects.SDK.Server.Service, ISchedule {
        private System.ComponentModel.Container components = null;
        public Schedule() :
            base() {
            this.InitializeComponent();
        }

        private void InitializeComponent() {
        }

        protected override void Dispose(bool aDisposing) {
            if(aDisposing) {
                if((this.components != null)) {
                    this.components.Dispose();
                }
            }
            base.Dispose(aDisposing);
        }
        
        public virtual AppointmentInfo1[] GetAppointments1(string apiKey, ProviderInfo1[] providerInfo, ResourceInfo1[] resourceInfo, System.DateTime startDate, System.DateTime endDate)
        {
            if (ProductType.IsKeyLytec(apiKey))
            {
                return LytecConnector.GetAppointments(apiKey, providerInfo, resourceInfo, startDate, endDate);
            }
            else if (ProductType.IsKeyMedisoft(apiKey))
            {
                return MedisoftConnector.GetAppointments(apiKey, providerInfo, resourceInfo, startDate, endDate);
            }

            MSLSpecific.Logger.Error("Invalid Product");
            return null;
        }

        public virtual AppointmentDetail1 GetAppointmentDetail1(string apiKey, int ApptID,bool bCalculateBalance)
        {
            if (ProductType.IsKeyLytec(apiKey))
            {
                return LytecConnector.GetAppointmentDetail(apiKey, ApptID, bCalculateBalance);
            }
            else if (ProductType.IsKeyMedisoft(apiKey))
            {
                return MedisoftConnector.GetAppointmentDetail(apiKey, ApptID, bCalculateBalance);
            }

            MSLSpecific.Logger.Error("Invalid Product");
            return null;
        }

        #region ISchedule Members

        public bool AddAppointment1(string apiKey, AppointmentInfo1 appointmentInfo) {
            return true;
        }

        #endregion
    }
}
