public void SaveDepartureLocations(ChauffeurRoute route, EventVenueMapping eventVenueMapping) { try { var eventVenueMappingTime = _eventVenueMappingTimeRepository.GetAllByEventVenueMappingId(eventVenueMapping.Id).FirstOrDefault(); if (eventVenueMappingTime == null) { eventVenueMappingTime = _eventVenueMappingTimeRepository.Save(new EventVenueMappingTime { EventVenueMappingId = eventVenueMapping.Id, PickupTime = null, PickupLocation = route.PickupLocation, ReturnTime = null, ReturnLocation = null, JourneyType = 1, IsEnabled = true, CreatedBy = Guid.NewGuid(), CreatedUtc = DateTime.UtcNow, UpdatedBy = null, UpdatedUtc = null, ModifiedBy = Guid.NewGuid() }); eventVenueMappingTime = _eventVenueMappingTimeRepository.Save(new EventVenueMappingTime { EventVenueMappingId = eventVenueMapping.Id, PickupTime = null, PickupLocation = route.PickupLocation, ReturnTime = null, ReturnLocation = null, JourneyType = 2, IsEnabled = true, CreatedBy = Guid.NewGuid(), CreatedUtc = DateTime.UtcNow, UpdatedBy = null, UpdatedUtc = null, ModifiedBy = Guid.NewGuid() }); } } catch (Exception ex) { _logger.Log(LogCategory.Error, ex); } }
public EventVenueMapping SaveToVenue(ChauffeurRoute routeDetail, Event @event, SaveLocationReturnValues locationValues) { try { var venue = _venueRepository.GetByVenueNameAndCityId(routeDetail.LocationHeader, locationValues.cityId); if (venue == null || venue.Name == null) { venue = _venueRepository.Save(new Venue { AltId = Guid.NewGuid(), Name = routeDetail.LocationHeader, AddressLineOne = routeDetail.PickupLocation, AddressLineTwo = routeDetail.PickupLocation, CityId = locationValues.cityId, Latitude = locationValues.lat.ToString(), Longitude = locationValues.lng.ToString(), ModifiedBy = @event.ModifiedBy, IsEnabled = true }); } var eventVenueMapping = _eventVenueMappingRepository.GetByEventIdAndVenueId(@event.Id, venue.Id); if (eventVenueMapping == null) { eventVenueMapping = _eventVenueMappingRepository.Save(new EventVenueMapping { EventId = @event.Id, VenueId = venue.Id, IsEnabled = true, CreatedUtc = DateTime.UtcNow, UpdatedUtc = null, CreatedBy = @event.ModifiedBy, UpdatedBy = null, ModifiedBy = @event.ModifiedBy }); } return(eventVenueMapping); } catch (Exception ex) { _logger.Log(LogCategory.Error, ex); return(new EventVenueMapping()); } }
public void SaveBlockedDates(ChauffeurRoute route, Event @event, EventDetail eventDetail) { foreach (var item in route.BlockedDate) { try { var placeHoliDayDates = _placeHolidayDatesRepository.GetByEventandDate(@event.Id, Convert.ToDateTime(item)); placeHoliDayDates = _placeHolidayDatesRepository.Save(new PlaceHolidayDate { LeaveDateTime = Convert.ToDateTime(item), EventId = @event.Id, IsEnabled = true, EventDetailId = eventDetail.Id, ModifiedBy = @event.ModifiedBy }); } catch (Exception ex) { _logger.Log(LogCategory.Error, ex); } } }
public void SaveTicketDetail(ChauffeurRoute route, EventDetail eventDetail, SaveLocationReturnValues cityAndCurrency) { var category = "Passengers"; try { var ticketCategory = _ticketCategoryRepository.GetByName(category); if (ticketCategory == null) { ticketCategory = _ticketCategoryRepository.Save(new TicketCategory { Name = category, ModifiedBy = eventDetail.ModifiedBy, IsEnabled = true }); } var eventTicketDetail = _eventTicketDetailRepository.GetByTicketCategoryIdAndEventDetailId(ticketCategory.Id, eventDetail.Id); if (eventTicketDetail == null) { eventTicketDetail = _eventTicketDetailRepository.Save(new EventTicketDetail { EventDetailId = eventDetail.Id, TicketCategoryId = ticketCategory.Id, ModifiedBy = eventDetail.ModifiedBy, IsEnabled = true }); } var eventTicketAttributeIn = new EventTicketAttribute { EventTicketDetailId = eventTicketDetail.Id, SalesStartDateTime = eventDetail.StartDateTime, SalesEndDatetime = eventDetail.EndDateTime, TicketTypeId = TicketType.Regular, ChannelId = Channels.Feel, CurrencyId = cityAndCurrency.currencyId, SharedInventoryGroupId = null, TicketCategoryDescription = $"Chauffeur Service Price from {route.LocationHeader}", ViewFromStand = string.Empty, IsSeatSelection = false, AvailableTicketForSale = 50, RemainingTicketForSale = 50, Price = Convert.ToDecimal(route.ReturnPrice) < 0 ? 0 : Convert.ToDecimal(route.ReturnPrice), IsInternationalCardAllowed = false, IsEMIApplicable = false, ModifiedBy = eventDetail.ModifiedBy, IsEnabled = true }; var eventTicketAttributeOut = _eventTicketAttributeRepository.GetByEventTicketDetailId(eventTicketDetail.Id); if (eventTicketAttributeOut == null) { eventTicketAttributeOut = _eventTicketAttributeRepository.Save(eventTicketAttributeIn); } else { eventTicketAttributeOut.Price = Convert.ToDecimal(route.ReturnPrice) < 0 ? 0 : Convert.ToDecimal(route.ReturnPrice); eventTicketAttributeOut = _eventTicketAttributeRepository.Save(eventTicketAttributeIn); } var ticketFeeDetail = _ticketFeeDetailRepository.GetByEventTicketAttributeIdAndFeedId(eventTicketAttributeOut.Id, (int)FeeType.ConvenienceCharge); if (ticketFeeDetail == null) { ticketFeeDetail = _ticketFeeDetailRepository.Save(new TicketFeeDetail { EventTicketAttributeId = eventTicketAttributeOut.Id, FeeId = (int)FeeType.ConvenienceCharge, DisplayName = "Convienence Charge", ValueTypeId = (int)ValueTypes.Percentage, Value = 5, ModifiedBy = eventDetail.ModifiedBy, IsEnabled = true }); } } catch (Exception ex) { _logger.Log(LogCategory.Error, ex); } }
public async Task <SaveLocationReturnValues> SaveCityStateCountry(ChauffeurRoute routeDetail, ValueRetailVillage village) { var locationData = await _googleMapApi.GetLatLongFromAddress(routeDetail.LocationHeader); try { if (!locationData.Success) { throw new ArgumentNullException(locationData.Result.CityName, "Failed to get Location Data"); } var countryCodeAndCurrency = await _countryAlphaCode.GetCountryCodeByName(locationData.Result.CountryName); var country = _countryRepository.GetByName(locationData.Result.CountryName); if (country == null) { country = _countryRepository.Save(new Country { Name = locationData.Result.CountryName, IsoAlphaTwoCode = countryCodeAndCurrency.Result.IsoAlphaTwoCode.ToUpper(), IsoAlphaThreeCode = countryCodeAndCurrency.Result.IsoAlphaThreeCode.ToUpper(), IsEnabled = true, }); } var state = _stateRepository.GetByNameAndCountryId(locationData.Result.StateName, country.Id); if (state == null) { state = _stateRepository.Save(new State { Name = locationData.Result.StateName, CountryId = country.Id, IsEnabled = true, }); } var city = _cityRepository.GetByNameAndStateId(locationData.Result.CityName, state.Id); if (city == null) { city = _cityRepository.Save(new City { Name = locationData.Result.CityName, StateId = state.Id, IsEnabled = true, }); } var currencyType = _currencyTypeRepository.GetByCurrencyCode(village.CurrencyCode.ToUpper()); if (currencyType == null) { currencyType = _currencyTypeRepository.Save(new CurrencyType { Code = village.CurrencyCode.ToUpper(), Name = village.CurrencyCode.ToUpper(), CountryId = country.Id, ModifiedBy = Guid.NewGuid(), IsEnabled = true }); } var values = new SaveLocationReturnValues { cityId = city.Id, currencyId = currencyType.Id, lat = locationData.Result.lat, lng = locationData.Result.lng }; return(values); } catch (Exception ex) { _logger.Log(LogCategory.Error, ex); return(new SaveLocationReturnValues()); } }
public Event SaveToEvent(ChauffeurRoute route, ValueRetailVillage valueRetailVillage) { var eventName = CheckAndTranslateLanguage(route.ServiceType); var @event = new Event { AltId = Guid.NewGuid(), Name = $"Chauffeur {eventName} from {route.LocationHeader} to {valueRetailVillage.VillageName}", EventCategoryId = ValueRetailEventCategoryConstant.ShoppingPackageParentCategory, EventTypeId = EventType.Perennial, Description = $"<p>{CheckAndTranslateLanguage(route.ServiceDescription)}</p>", ClientPointOfContactId = 2, FbEventId = null, MetaDetails = null, IsFeel = true, EventSourceId = EventSource.ValueRetail, TermsAndConditions = "", IsPublishedOnSite = true, PublishedDateTime = DateTime.Now, PublishedBy = null, TestedBy = null, Slug = $"{eventName} {route.LocationHeader}".Replace(" ", "-"), ModifiedBy = Guid.NewGuid(), IsEnabled = true }; try { var eventResult = _eventRepository.GetByEventName(@event.Name); if (eventResult == null) { eventResult = _eventRepository.Save(@event); } var eventSiteIdMapping = _eventSiteIdMappingRepository.GetByEventId(eventResult.Id); if (eventSiteIdMapping == null) { eventSiteIdMapping = _eventSiteIdMappingRepository.Save(new Contracts.DataModels.EventSiteIdMapping { EventId = eventResult.Id, SortOrder = 999, SiteId = Site.feelaplaceSite, ModifiedBy = eventResult.ModifiedBy, IsEnabled = true }); } var eventCategoryMapping = _eventCategoryMappingRepository.GetByEventId(eventResult.Id).FirstOrDefault(); if (eventCategoryMapping == null) { _eventCategoryMappingRepository.Save(new Contracts.DataModels.EventCategoryMapping { EventId = eventResult.Id, EventCategoryId = ValueRetailEventCategoryConstant.ChauffeurDriveChildCategory, ModifiedBy = eventResult.ModifiedBy, IsEnabled = true }); } var days = _daysRepository.GetAll(); foreach (var day in days) { var placeweekOpenDays = _placeWeekOpenDaysRepository.GetByEventIdandDayId(eventResult.Id, day.Id); if (placeweekOpenDays == null) { placeweekOpenDays = _placeWeekOpenDaysRepository.Save(new PlaceWeekOpenDays { AltId = Guid.NewGuid(), EventId = eventResult.Id, DayId = day.Id, IsSameTime = false, ModifiedBy = eventResult.ModifiedBy, IsEnabled = true }); } } return(eventResult); } catch (Exception ex) { _logger.Log(LogCategory.Error, ex); return(new Event()); } }