Esempio n. 1
0
		public async Task<List<VTSModel>> GetVTSList ()
		{
			ModelConverter converter = new ModelConverter ();
			List<VacationInfoModel> listVacationInfoModel;

			try {
				RestService restService = new RestService ("/api/Vacations", Server);
				listVacationInfoModel = await restService.Get<VacationInfoModel> ();
			} catch (AggregateException e) {
				//ErrorMessage = e.InnerExceptions [0].Data ["message"].ToString ();
				listVacationInfoModel = null;
			}

			SQLiteService sqliteService;
			try {
				sqliteService = new SQLiteService (_sqlitePlatform, await _fileSystem.GetPath ("VTS"));
			} catch {
				sqliteService = null;
			}

			List<VTSModel> VTSViewModelList = new List<VTSModel> ();
			VTSModel newItem;

			listVacationInfoModel = new VacationInfoMockModel ().Vacations;


			if (listVacationInfoModel != null) {
				foreach (VacationInfoModel info in listVacationInfoModel) {
					newItem = converter.ConvertToVTSModel (info);
					VTSViewModelList.Add (newItem);
					if (sqliteService != null) {
						await sqliteService.Insert<VacationInfoDTO> (converter.ConvertToVacationInfoDTO (newItem));
					}
				}
			} else if(sqliteService != null) {
				List<VacationInfoDTO> vacationInfoList = await sqliteService.Get<VacationInfoDTO> ();
				if (vacationInfoList != null) {
					foreach (VacationInfoDTO info in vacationInfoList) {
						VTSViewModelList.Add (converter.ConvertToVTSModel (info));
					}
				}
			}
		
			return VTSViewModelList;
		}
Esempio n. 2
0
		public async Task<VTSModel> GetVacationInfo (string id)
		{
			ModelConverter converter = new ModelConverter ();

			SQLiteService sqliteService;
			try {
				sqliteService = new SQLiteService (_sqlitePlatform, await _fileSystem.GetPath ("VTS"));
			} catch {
				sqliteService = null;
			}
			VacationInfoDTO info =await sqliteService.Get<VacationInfoDTO> (id);
			return  converter.ConvertToVTSModel(info);
		}