private void EventItemClicked(EventItemViewModel eventVM) { if (eventVM.Unavaiability == null) { Debug.WriteLine("Receive click on Booking ???"); SelectedEvent = eventVM; ShowViewModel <AddEventViewModel> (new { unavailabilityId = string.Empty, parkingId = ParkingId, isEditMode = true, title = eventVM.Booking.PlateNumber, startTime = eventVM.Booking.StartTimestamp, endTime = eventVM.Booking.EndTimestamp, repeat = (eventVM.Unavaiability != null && eventVM.Unavaiability.Periodicity != null && !string.IsNullOrEmpty(eventVM.Unavaiability.Periodicity.Repeat)) ? eventVM.Unavaiability.Periodicity.Repeat : string.Empty, time = (eventVM.Unavaiability != null && eventVM.Unavaiability.Periodicity != null && !string.IsNullOrEmpty(eventVM.Unavaiability.Periodicity.OccurrencesAmount)) ? eventVM.Unavaiability.Periodicity.OccurrencesAmount : string.Empty }); //mCacheService.CurrentReservation = eventVM.Booking; //ShowViewModel<ParkingReservedViewModel> (new { status = ParkingStatus.Reserved, isReadOnly = true }); } else { var ParentEvent = SaveEventsUnsort.FirstOrDefault(x => x.Unavaiability.UnavailabilityId == eventVM.Unavaiability.UnavailabilityId); long block = ParentEvent.Unavaiability.EndTimestamp - ParentEvent.Unavaiability.StartTimestamp; long starTimestamp = ParentEvent.Unavaiability.StartTimestamp; long endTimestamp = ParentEvent.Unavaiability.EndTimestamp; var occurences = ParentEvent.Unavaiability.Periodicity.Occurrences.FirstOrDefault(x => x.StartTimestamp == eventVM.Unavaiability.StartTimestamp); if (occurences != null) { starTimestamp = occurences.StartTimestamp; endTimestamp = starTimestamp + block; } if (eventVM.Unavaiability != null && ParentEvent != null) { SelectedEvent = eventVM; ShowViewModel <AddEventViewModel> (new { unavailabilityId = eventVM.Unavaiability != null ? eventVM.Unavaiability.UnavailabilityId : string.Empty, parkingId = ParkingId, isEditMode = true, title = eventVM.Unavaiability.Title, startTime = starTimestamp, endTime = endTimestamp, repeat = (eventVM.Unavaiability.Periodicity != null && !string.IsNullOrEmpty(eventVM.Unavaiability.Periodicity.Repeat)) ? eventVM.Unavaiability.Periodicity.Repeat : string.Empty, time = (eventVM.Unavaiability.Periodicity != null && !string.IsNullOrEmpty(eventVM.Unavaiability.Periodicity.OccurrencesAmount)) ? eventVM.Unavaiability.Periodicity.OccurrencesAmount : string.Empty }); } } }
private void DeleteEvent(EventItemViewModel eventVM) { Mvx.Resolve <IMvxMessenger>().Publish(new AlertMessage(this, SharedTextSource.GetText("DeleteEventText"), SharedTextSource.GetText("AreYouSureDeleteEventText"), SharedTextSource.GetText("NoText"), null, new string[] { SharedTextSource.GetText("DeleteEventOnlyText"), SharedTextSource.GetText("DeleteFutureEventsText") }, async() => { if (BaseView != null && BaseView.CheckInternetConnection()) { Mvx.Resolve <IMvxMessenger>().Publish(new ProgressMessage(this, true)); var result = await mApiService.DeleteUnavailabilities(Mvx.Resolve <ICacheService>().CurrentUser.UserId, ParkingId, eventVM.Unavaiability.UnavailabilityId); if (result != null) { //Mvx.Resolve<IMvxMessenger>().Publish(new ToastMessage(this, result.Result)); //Mvx.Resolve<IMvxMessenger>().Publish(new ToastMessage(this, result.Result.Equals("success") ? result.Result : string.Format("{0}: {1}", result.Result, result.ErrorCode))); if (result) { Mvx.Resolve <IMvxMessenger>().Publish(new ToastMessage(this, "Success")); if (Events.Contains(eventVM)) { Events.Remove(eventVM); } if (View != null) { View.UpdateCalendar(true); } } else { Mvx.Resolve <IMvxMessenger>().Publish(new AlertMessage(this, string.Empty, string.Format("{0}: {1}", "", ""), "Ok", null)); } } Mvx.Resolve <IMvxMessenger>().Publish(new ProgressMessage(this, false)); } else { Mvx.Resolve <IMvxMessenger>().Publish(new ToastMessage(this, SharedTextSource.GetText("TurnOnInternetText"))); } }, async() => { if (BaseView != null && BaseView.CheckInternetConnection()) { Mvx.Resolve <IMvxMessenger>().Publish(new ProgressMessage(this, true)); var result = await mApiService.DeleteUnavailabilities(Mvx.Resolve <ICacheService>().CurrentUser.UserId, ParkingId, eventVM.Unavaiability.UnavailabilityId); if (result != null) { //Mvx.Resolve<IMvxMessenger>().Publish(new ToastMessage(this, result.Result)); //Mvx.Resolve<IMvxMessenger>().Publish(new ToastMessage(this, result.Result.Equals("success") ? result.Result : string.Format("{0}: {1}", result.Result, result.ErrorCode))); if (result) { Mvx.Resolve <IMvxMessenger>().Publish(new ToastMessage(this, "Success")); if (View != null) { View.UpdateCalendar(); } } else { Mvx.Resolve <IMvxMessenger>().Publish(new AlertMessage(this, string.Empty, string.Format("{0}: {1}", "", ""), "Ok", null)); } } Mvx.Resolve <IMvxMessenger>().Publish(new ProgressMessage(this, false)); // Android only: When dismiss delete dialog, Android cannot call resume to call GetUnavaiabilities so we call manual if (AddSpotCalendarTabView != null) { AddSpotCalendarTabView.GetUnavaiabilities(); } /////////////////////////////// } else { Mvx.Resolve <IMvxMessenger>().Publish(new ToastMessage(this, SharedTextSource.GetText("TurnOnInternetText"))); } })); }