﻿var sSchedule_dataSources_programDivisionDataSource = function () {

	//#region ------------------- ' Variables '-----------------------

	var dataSource = new sSchedule_dataSources();
	var models = new sSchedule_common_dataModels();
	var common = new Sschedule_commonFunctions();
	var serviceRootUrl = common.getServiceRootUrl();

	//#endregion ------------------- ' Variables '-----------------------

	function getDsByName(name, parameterMapFunc, successCallback, readCallBack) {
		var programDivisionDataSource = null;
		var apiName = null;
		var readEntity = null;
		var crudServiceUrl = null;

		switch (name) {
			case "ProgramDivisionTreeListDs":
				{
					apiName = "ProgramDivision";
					readEntity = "GetAllProgramsWithDivisionsTeams";
					crudServiceUrl = serviceRootUrl + apiName + "/";

					programDivisionDataSource = new kendo.data.HierarchicalDataSource({
						type: "json",
						transport:
							{
								read: dataSource.readDs(crudServiceUrl, readEntity, readCallBack),
								parameterMap: parameterMapFunc,
							},
						schema: {
							model: {
								hasChildren: "HasChildren",
								id: "Id",
								Name: "Name",
								children: "ChildItems"
							}
						},
						error: dataSource.errorDs(),
					});
				}
				break;
		}
		return programDivisionDataSource;
	}
	return {
		getDsByName: getDsByName
	};
}