Exemplo n.º 1
0
		public VTSModel ConvertToVTSModel(VacationInfoModel vacationInfo)
		{			
			VTSModel vtsModel = new VTSModel();

			vtsModel.Id = vacationInfo.Id;
			if (vacationInfo.Type != null) {
				vtsModel.VacationType = vacationInfo.Type.Value;
			}

			vtsModel.StartDate = vacationInfo.StartDate;
			vtsModel.EndDate = vacationInfo.EndDate;

			var startDate = (new DateTime (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).AddMilliseconds (vacationInfo.StartDate).ToLocalTime ().ToString ("MMM dd, yyyy");
			var endDate = (new DateTime (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).AddMilliseconds (vacationInfo.EndDate).ToLocalTime ().ToString ("MMM dd, yyyy"); 
			var dayCount = (new DateTime ()).AddMilliseconds (vacationInfo.EndDate - vacationInfo.StartDate).Day;
			vtsModel.Date = startDate + " - " + endDate + " (" + dayCount + " days)";

			if (vacationInfo.Approver != null) {
				if (vacationInfo.Approver.ImageSRC != null) {
					vtsModel.ImageSRC = new Uri (vacationInfo.Approver.ImageSRC);
				}
			}

			if (vacationInfo.Status != null) {
				vtsModel.Status = vacationInfo.Status.Icon;//ImageSource.FromFile(vacationInfo.Status.Icon);
			}

			return vtsModel;
		}
Exemplo n.º 2
0
		public VacationInfoDTO ConvertToVacationInfoDTO(VTSModel vts)
		{
			VacationInfoDTO vacationInfo = new VacationInfoDTO();
			vacationInfo.Id = vts.Id;
			vacationInfo.Date = vts.Date;
			vacationInfo.Status = vts.Status;
			vacationInfo.VacationType = vts.VacationType;
			vacationInfo.ImageSRC = (vts.ImageSRC == null)? null : vts.ImageSRC.ToString ();
			vacationInfo.Image = vts.Image;
			//vacationInfo.StartDate = vts.StartDate;
			//vacationInfo.EndDate = vts.EndDate;

			return vacationInfo;
		}
Exemplo n.º 3
0
		public async Task SaveVacationInfo (VTSModel newItem)
		{
			ModelConverter converter = new ModelConverter ();

			SQLiteService sqliteService;
			try {
				sqliteService = new SQLiteService (_sqlitePlatform, await _fileSystem.GetPath ("VTS"));
			} catch {
				sqliteService = null;
			}
			VacationInfoDTO dt = converter.ConvertToVacationInfoDTO (newItem);
			await sqliteService.Insert<VacationInfoDTO> (dt);

			RestService restService = new RestService ("/api/Vacations", Server);
			var req = await restService.Post<VacationInfoModel> (converter.ConvertToVacationInfoModel(newItem));
		}
Exemplo n.º 4
0
		public VTSModel ConvertToVTSModel(VacationInfoDTO vacationInfo)
		{
			VTSModel vts = new VTSModel();
			vts.Id = vacationInfo.Id;
			vts.Date = vacationInfo.Date;
			vts.Status = vacationInfo.Status;
			vts.VacationType = vacationInfo.VacationType;
			vts.Image = vacationInfo.Image;
			//vts.StartDate = vacationInfo.StartDate;
			//vts.EndDate = vacationInfo.EndDate;

			if (vacationInfo.ImageSRC != null) {
				vts.ImageSRC = new Uri (vacationInfo.ImageSRC);
			}

			return vts;
		}
Exemplo n.º 5
0
		public VacationInfoModel ConvertToVacationInfoModel(VTSModel vtsModel){
			VacationInfoModel info = new VacationInfoModel();
			info.Id = vtsModel.Id;
			info.Status =VacationInfoMockModel.VAC;
			return info;
		}