// Crud Handlers protected virtual void UpdateRecordHandler(UpdateRecordMessage <T> message) { // index out of range error bool indexInList = dataSource.Count > message.Index; if (!indexInList) { SendCrudMessage( CrudOperationMessage.CrudOperation.Update, CrudOperationMessage.CrudResult.Error); return; } T record = DataConnection.Update(message.Record); if (record == null) { SendCrudMessage( CrudOperationMessage.CrudOperation.Update, CrudOperationMessage.CrudResult.Error); return; } // this part needs to be overidable UpdateRecord(message.Index, message.Record); //dataSource[message.Index] = message.Record; view.RefreshTable(); // Raise update success SendCrudMessage( CrudOperationMessage.CrudOperation.Update, CrudOperationMessage.CrudResult.Success); }
private void UpdateTriggerHandler(object sender, EventArgs e) { CarModel car = selectedCar.Record; PopulateCar(car); UpdateRecordMessage <CarModel> updateMessage = new UpdateRecordMessage <CarModel>(car, selectedCar.Index); eventAggregator.Publish(updateMessage); SetStateDefault(); }
private void UpdateTriggerHandler(object sender, EventArgs e) { UserModel customer = selectedCustomer.Record; PopulateCustomer(customer as CustomerModel); UpdateRecordMessage <UserModel> updateMessage = new UpdateRecordMessage <UserModel>(customer, selectedCustomer.Index); eventAggregator.Publish(updateMessage); SetStateDefault(); }
private void UpdateTriggerHandler(object sender, EventArgs e) { bool carValid = ValidateCarField(); bool customerValid = ValidateCustomerField(); if (!carValid || !customerValid) { view.ShowAlertMessage( new AlertMessage(AlertMessage.MessageType.Error, Messages.ERROR_FORM_FILL)); return; } int carId = (view.Car as CarModel).ID; // If the car for the offer wasn't changed if (carId == selectedReservation.Record.CarID) { // Do update offer date validation if (!ValidateUpdateReservationPeriod()) { view.ShowAlertMessage( new AlertMessage(AlertMessage.MessageType.Error, Messages.ERROR_NO_TIME_PERIOD)); return; } } else { // Do new offer date validation if (!ValidateNewReservationPeriod()) { view.ShowAlertMessage( new AlertMessage(AlertMessage.MessageType.Error, Messages.ERROR_NO_TIME_PERIOD)); return; } } ReservationModel Reservation = selectedReservation.Record; PopulateReservation(Reservation); UpdateRecordMessage <ReservationModel> updateMessage = new UpdateRecordMessage <ReservationModel>(Reservation, selectedReservation.Index); eventAggregator.Publish(updateMessage); SetStateDefault(); }
private void UpdateTriggerHandler(object sender, EventArgs e) { bool priceValid = ValidatePriceField(); bool carValid = ValidateCarField(); if (!priceValid || !carValid) { view.ShowAlertMessage( new AlertMessage(AlertMessage.MessageType.Error, Messages.ERROR_FORM_FILL)); return; } // Do date validations int carId = (view.Car as CarModel).ID; // If the car for the offer wasn't changed if (carId == selectedOffer.Record.CarID) { // Do update offer date validation if (!ValidateUpdateOfferDate()) { view.ShowAlertMessage( new AlertMessage(AlertMessage.MessageType.Error, Messages.ERROR_NO_TIME_PERIOD)); return; } } else { // Do new offer date validation if (!ValidateNewOfferPeriod()) { view.ShowAlertMessage( new AlertMessage(AlertMessage.MessageType.Error, Messages.ERROR_NO_TIME_PERIOD)); return; } } OfferModel Offer = selectedOffer.Record; PopulateOffer(Offer); UpdateRecordMessage <OfferModel> updateMessage = new UpdateRecordMessage <OfferModel>(Offer, selectedOffer.Index); eventAggregator.Publish(updateMessage); SetStateDefault(); }