private async Task <bool> ExecuteSecondDriverResult(IBookingData request) { if (request == null) { return(false); } if (request.Value == null) { return(false); } try { using (var connection = SqlExecutor.OpenNewDbConnection()) { BookingViewObject dto = request.Value; var secondDriverStore = _queryStoreFactory.GetQueryStore(); secondDriverStore.AddParamCount(QueryType.QueryCity, dto.DRV2_CITY); secondDriverStore.AddParamCount(QueryType.QueryCountry, dto.DRV2_ID_CARD_COU_CODE); secondDriverStore.AddParamCount(QueryType.QueryProvince, dto.DRV2_ZIP_CODE); var secondDriverQuery = secondDriverStore.BuildQuery(); var driverResult = await connection.QueryMultipleAsync(secondDriverQuery).ConfigureAwait(false); request.SecondDriverCityDto = SelectionHelpers.WrappedSelectedDto <POBLACIONES, CityViewObject>(request.Value.DRV2_CITY, _mapper, driverResult); request.SecondDriverCountryDto = SelectionHelpers.WrappedSelectedDto <Country, CountryViewObject>(request.Value.DRV2_ID_CARD_COU_CODE, _mapper, driverResult); request.SecondDriverProvinceDto = SelectionHelpers.WrappedSelectedDto <PROVINCIA, ProvinceViewObject>(request.Value.DRV2_ZIP_CODE, _mapper, driverResult); } } catch (System.Exception ex) { throw new DataAccessLayerException("Parsing multiple query result error", ex); } return(true); }
/// <summary> /// Get a new data object /// </summary> /// <param name="code">Office code for the booking</param> /// <returns>Returns if the data is fetched with success.</returns> public IBookingData GetNewDo(string code) { var bookingValue = new RESERVAS1(); var officeCode = code.Substring(0, 2); var bookingData = new Reservation() { Valid = true }; using (var connection = SqlExecutor.OpenNewDbConnection()) { if (connection == null) { return(bookingData); } var bookingNumber = connection.UniqueId <RESERVAS1>(bookingValue, null, null, officeCode); var bookingDto = new BookingViewObject { FECHA_RES1 = DateTime.Now, HORA_RES1 = DateTime.Now.TimeOfDay, NUMERO_RES = bookingNumber, SUBLICEN_RES1 = "00", OFICINA_RES1 = officeCode, IsNew = true }; bookingData.Value = bookingDto; } return(bookingData); }
public NullReservation() { _bookingDto = new BookingViewObject(); _isValid = false; _bookingItems = new List <BookingItemsViewObject>(); _base = new HelperBase(); _contracts = new ObservableCollection <ContractSummaryDto>(); _clients = new ObservableCollection <ClientSummaryExtended>(); _drivers = new ObservableCollection <ClientSummaryExtended>(); }
/// <summary> /// This validate the booking viewObject. /// </summary> /// <param name="viewObject">Booking data object to be validated.</param> public void Validate(BookingViewObject viewObject) { System.ComponentModel.DataAnnotations.ValidationContext context = new System.ComponentModel.DataAnnotations.ValidationContext(viewObject, null, null); List <ValidationResult> results = new List <ValidationResult>(); bool valid = Validator.TryValidateObject(viewObject, context, results, true); if (!valid) { throw new DataAccessLayerException("Booking is not valid"); } if (viewObject == null) { throw new DataAccessLayerException("Booking is null"); } if (viewObject.Items == null) { throw new DataAccessLayerException("Items are null"); } if (string.IsNullOrEmpty(viewObject.CLIENTE_RES1)) { throw new DataAccessLayerException("Client should be not empty"); } if (string.IsNullOrEmpty(viewObject.CONDUCTOR_RES1)) { throw new DataAccessLayerException("Conductor should be not empty"); } if (string.IsNullOrEmpty(viewObject.NUMERO_RES)) { throw new DataAccessLayerException("Reservation number should be not empty"); } }
/// <summary> /// Create a booking from a pdf or a memory image stream. /// </summary> /// <param name="viewObject"></param> /// <param name="image"></param> public BookingPdfCreator(BookingViewObject viewObject, MemoryStream image) { _viewObjectValue = viewObject; _imageStream = image; }
public bool CanCreate(BookingViewObject valueObject) { return(true); }
public bool CanChange(BookingViewObject valueObject) { _value = valueObject; return(true); }
public BookingService(BookingViewObject viewObject) { }
public Reservation() { Value = new BookingViewObject(); Valid = true; InitFields(); }