Example #1
0
		public void ShowVisitDetails(VMVisit visit)
		{
			if (visit == null)
				return;
			var popupViewController = new PopupViewController {View = {Frame = View.Bounds}};
			//popupViewController.ContentView = new UIView(new RectangleF(0,0,200,200)){BackgroundColor = UIColor.Red};
			popupViewController.ContentView = new VisitDetailsView
			{
				Parent = popupViewController,
				Visit = visit,
				MainPage = mainView.ViewModel,
				Close = ()=> popupViewController.Hide()
			};
			popupViewController.Show(this.NavigationController);
		}
Example #2
0
		public async Task<bool> Save(VMVisit vmVisit)
		{
			try
			{
				var visit = new Visit
				{
					VisitId = vmVisit.VisitId,
					EmployeeId = vmVisit.Employee.EmployeeId,
					VisitorId = vmVisit.VisitorId,
					VisitDateTime = vmVisit.VisitDate,
					Comments = vmVisit.Comment,
					HasCar = vmVisit.HasCar,
					Plate = vmVisit.Plate,
				};
				if (visit.VisitId > 0)
				{
					await this.clientService.VisitService.Update(visit);
					return true;
				}

				var result = await this.clientService.VisitService.Add(visit);
				return true;
			}
			catch (Exception exception)
			{
				Console.WriteLine(exception);
				return false;
			}
		}
Example #3
0
		async void OnVisitAdded(Visit visit)
		{
			//await App.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
			{
				bool isNext = NextVisit == null || visit.VisitDateTime < NextVisit.VisitDate;

				bool isToday = visit.VisitDateTime.ToLocalTime().Date == DateTime.Now.Date;
				ObservableCollection<VMVisit> list = isToday ? TodayVisits : OtherVisits;
				int maxNumberOfItems = isToday ? ITEMS_TO_RETRIEVE_TODAY : ITEMS_TO_RETRIEVE_OTHER;
				int visitGroup = isToday ? TODAY_GROUP_ID : OTHER_GROUP_ID;
				var VMVisit = new VMVisit(visit, visitGroup);

				VMVisit previousVisit = list.LastOrDefault(v => v.VisitDate < VMVisit.VisitDate);

				int visitIndex = previousVisit == null ? 0 : list.IndexOf(previousVisit) + 1;

				bool hasToBeAdded = visitIndex <= list.Count;
				bool needToRemoveLast = list.Count() == maxNumberOfItems;

				if (isNext)
					NextVisit = VMVisit;

				if (hasToBeAdded)
				{
					list.Insert(visitIndex, VMVisit);
				}

				if (needToRemoveLast)
				{
					list.Remove(list.Last());
				}

				if (isToday)
				{
					ShowTodayVisits = true;
					TodayVisitsCount++;
				}
				else
				{
					ShowOtherVisits = true;
					OtherVisitsCount++;
				}

				RaisePropertyChanged(() => ShowNextVisit);
			}
			//);
		}
Example #4
0
		/// <summary>
		///     This method get the 9 first visits others than today visits.
		/// </summary>
		/// <returns></returns>
		async Task<int> GetOtherVisits()
		{
			IList<Visit> otherResults =
				await
					clientService.VisitService.GetVisitsFromDate(string.Empty, PictureType.Small, ITEMS_TO_RETRIEVE_OTHER,
						ITEMS_TO_RETRIEVE_PAGEZERO, DateTime.Today.AddDays(1).ToUniversalTime());
			//int otherItems = await this.clientService.VisitService.GetCountFromDate(string.Empty, DateTime.Today.AddDays(1).ToUniversalTime());
			int otherItems = 35;

			ShowOtherVisits = otherResults.Any();
			OtherVisits = new ObservableCollection<VMVisit>(otherResults.Select(v => new VMVisit(v, OTHER_GROUP_ID)));

			if (otherResults.Any() && NextVisit == null)
			{
				// Set the next visit of another day.
				int id = otherResults.First().VisitId;
				Visit nextVisit = await clientService.VisitService.Get(id, PictureType.Big);
				NextVisit = new VMVisit(nextVisit, TODAY_GROUP_ID);
			}
			OtherVisitsCount = otherItems;

			return otherItems;
		}