private async Task <GenericReadModelResponse <string> > CreateBookingAsync(ProceedBookingRequest webRequest, string paxId) { var response = new GenericReadModelResponse <string>(); var bookingProductModel = new BookingProductModel { ProductId = webRequest.ProductId, DateCheckIn = webRequest.BookDate, PaxIds = new string[] { paxId }, Nights = 1 }; var apiRequest = new CreateBookingRequest(); apiRequest.BookingProducts.Add(bookingProductModel); var apiResponse = await this._heroApiManager.CreateBookingAsync(apiRequest); if (apiResponse.IsError()) { response.AddErrorMessages(apiResponse.GetErrorMessages()); return(response); } response.Model = apiResponse.Model.Id; return(response); }
public async Task <GenericReadModelResponse <ProductPriceModel> > GetProductPriceAsync(int productId, DateTime dateCheckIn) { var response = new GenericReadModelResponse <ProductPriceModel>(); var httpTask = _httpClient.PostAsync($"productpricing/{productId}?dateCheckIn={dateCheckIn.ToString("s")}", null); var apiResult = await SendApiRequest <ProductPriceModel>(response, httpTask); if (response.IsError()) { return(response); } response.Model = apiResult; return(response); }
public async Task <GenericReadModelResponse <BookingVoucherModel> > GetVoucherAsync(string bookingId, string paxId) { var response = new GenericReadModelResponse <BookingVoucherModel>(); var httpTask = _httpClient.GetAsync($"vouchers/{bookingId}/{paxId}"); var apiResult = await SendApiRequest <BookingVoucherModel>(response, httpTask); if (response.IsError()) { return(response); } response.Model = apiResult; return(response); }
public async Task <GenericReadModelResponse <string> > FinalizeBookingAsync(string bookingId) { var response = new GenericReadModelResponse <string>(); var httpTask = _httpClient.GetAsync($"bookingfinalise/{bookingId}"); var apiResult = await SendApiRequest <string>(response, httpTask); if (response.IsError()) { return(response); } response.Model = apiResult; return(response); }
public async Task <GenericReadModelResponse <BookingModel> > CreateBookingAsync(CreateBookingRequest createBookingRequest) { var response = new GenericReadModelResponse <BookingModel>(); var JsonBodyContent = JsonConvert.SerializeObject(createBookingRequest); var httpContent = new StringContent(JsonBodyContent, Encoding.UTF8, "application/json"); var httpTask = _httpClient.PostAsync("bookings", httpContent); var apiResult = await SendApiRequest <BookingModel>(response, httpTask); if (response.IsError()) { return(response); } response.Model = apiResult; return(response); }
private async Task <GenericReadModelResponse <string> > CreatePax(ProceedBookingRequest webRequest) { var response = new GenericReadModelResponse <string>(); var apiRequest = new CreatePaxRequest { FirstName = webRequest.FirstName, LastName = webRequest.LastName, PhoneNumber = webRequest.PhoneNumber, EmailAddress = webRequest.EmailAddress }; var apiResponse = await this._heroApiManager.CreatePaxAsync(apiRequest); if (apiResponse.IsError()) { response.AddErrorMessages(apiResponse.GetErrorMessages()); return(response); } response.Model = apiResponse.Model.Id; return(response); }
private async Task <GenericReadModelResponse <double> > GetTotalPriceAsync(int productId, string bookDate) { var response = new GenericReadModelResponse <double>(); DateTime.TryParse(bookDate, out DateTime bookingDateTime); var apiResponse = await this._heroApiManager.GetProductPriceAsync(productId, bookingDateTime); if (apiResponse.IsError()) { response.AddErrorMessages(apiResponse.GetErrorMessages()); return(response); } var model = apiResponse.Model; var discount = model.Commission * 0.5; var totalPriceAfterDiscount = model.TotalPrice - discount; response.Model = totalPriceAfterDiscount; return(response); }