//==================================================================================================== public AddBookingViewModel(IMessageBoxService mboxService, IConfigService configService, IParentVm parent, Booking model) { _parent = parent; _mboxService = mboxService; _configService = configService; //Get Configuration AvailableDurations = _configService.GetAvailableDurations(); //Set Commands SubmitCommand = new ActionCommand(OnSubmit, _=>_isFormValid); CancelCommand = new ActionCommand(OnCancel); //Set up the screen for Add or Display. if (model.Id == -1) { Model = model; Caption = "Add New Booking"; IsAddMode = true; } else { Model = model; Caption = "Existing Booking"; IsAddMode = false; } }
private void OnCancel(object o) { Model = new Booking();//Clear, just in case _parent.Cancel(); }
private void OpenBookingView(Booking model) { BookingVm = new AddBookingViewModel(_mboxService, _configService, this, model); IsBookingViewOpen = true; }
//==================================================================================================== public void Submit(Booking booking) { //This is where we would do some checking to see if Model.Id was populated (for example) //and if it was it would be a save call and not and add call _bookingService.AddBookingAsync(booking, AddToBookings, HandleErrors); CloseBookingView(); }
private void AddToBookings(Booking b) { OnUIThread(() =>Bookings.Add(b)); }