namespace MvcApplication1.Models
{
	using System.Collections.Generic;
	using System.Web.Script.Services;
	using System.Web.Services;
	using System.Web.SessionState;
	using Telerik.Web.UI;

	/// <summary>
	/// RadScheduler data service.
	/// </summary>
	[WebService]
	[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
	[ScriptService]
	public class SchedulerWebService : WebService, IRequiresSessionState
	{
		private WebServiceAppointmentController _controller;
		public const string ProviderSessionKey = "SchedulerWebServiceData";

		private WebServiceAppointmentController Controller
		{
			get
			{
				if (_controller == null)
				{
					// XmlSchedulerProvider is configured in web.config
					_controller = new WebServiceAppointmentController("XmlSchedulerProvider");
				}

				return _controller;
			}
		}

		[WebMethod(EnableSession = true)]
		public IEnumerable<AppointmentData> GetAppointments(SchedulerInfo schedulerInfo)
		{
			return Controller.GetAppointments(schedulerInfo);
		}

		[WebMethod(EnableSession = true)]
		public IEnumerable<AppointmentData> InsertAppointment(SchedulerInfo schedulerInfo, AppointmentData appointmentData)
		{
			return Controller.InsertAppointment(schedulerInfo, appointmentData);
		}

		[WebMethod(EnableSession = true)]
		public IEnumerable<AppointmentData> UpdateAppointment(SchedulerInfo schedulerInfo, AppointmentData appointmentData)
		{
			return Controller.UpdateAppointment(schedulerInfo, appointmentData);
		}

		[WebMethod(EnableSession = true)]
		public IEnumerable<AppointmentData> CreateRecurrenceException(SchedulerInfo schedulerInfo, AppointmentData recurrenceExceptionData)
		{
			return Controller.CreateRecurrenceException(schedulerInfo, recurrenceExceptionData);
		}

		[WebMethod(EnableSession = true)]
		public IEnumerable<AppointmentData> RemoveRecurrenceExceptions(SchedulerInfo schedulerInfo, AppointmentData masterAppointmentData)
		{
			return Controller.RemoveRecurrenceExceptions(schedulerInfo, masterAppointmentData);
		}

		[WebMethod(EnableSession = true)]
		public IEnumerable<AppointmentData> DeleteAppointment(SchedulerInfo schedulerInfo, AppointmentData appointmentData, bool deleteSeries)
		{
			return Controller.DeleteAppointment(schedulerInfo, appointmentData, deleteSeries);
		}

		[WebMethod(EnableSession = true)]
		public IEnumerable<ResourceData> GetResources(SchedulerInfo schedulerInfo)
		{
			return Controller.GetResources(schedulerInfo);
		}

	}


}
