Beispiel #1
0
        public ActionResult Create(CreateTicketViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var newTicket = new Ticket
                {
                    TicketCategoryId    = vm.TicketCategoryId,
                    TicketSubCategoryId = vm.TicketSubCategoryId,
                    Title            = vm.Title,
                    Description      = vm.Description,
                    DueDate          = vm.DueDate,
                    Status           = vm.Status,
                    AssignedToUserId = vm.AssignedToUserId,
                    CreatedByUserId  = WebUser.Id
                };

                // Assign to Default point of contact.
                var selectedCategory = _ticketCategoryRepository.Get(vm.TicketCategoryId);
                var pointOfContact   = _ticketService.GetPointOfContact(selectedCategory.Title);
                newTicket.AssignedToUserId = pointOfContact;

                _ticketRepository.Create(newTicket);
                _unitOfWork.Commit();

                #if !DEBUG
                _emailComposerService.TicketCreated(newTicket.Id);
                #endif

                return(RedirectToAction("Index"));
            }

            // Special Case where the sub categories should be based on the category
            var categories    = _ticketCategoryRepository.GetAll().ToList();
            var subCategories = _ticketSubCategoryRepository.GetAllBy(s => s.TicketCategoryId == vm.TicketCategoryId);

            ViewBag.TicketCategoryId    = new SelectList(categories, "Id", "Title", vm.TicketCategoryId);
            ViewBag.TicketSubCategoryId = new SelectList(subCategories, "Id", "Title", vm.TicketSubCategoryId);
            return(View());
        }
Beispiel #2
0
        public BarcodeQueryResult Handle(BarcodeQuery query)
        {
            try
            {
                var eventTicketDetails = _eventTicketDetailRepository.GetRASVRideEventTicketDetails()
                                         .ToDictionary(k => k.Id, k => k);

                var matchSeatTicketDetail = _matchSeatTicketDetailRepository.GetByBarcodeNumberAndEventTicketDetailIds(query.BarcodeNumber, eventTicketDetails.Keys);
                if (matchSeatTicketDetail != null)
                {
                    var transaction        = _transactionRepository.Get((long)matchSeatTicketDetail.TransactionId);
                    var eventTicketDetail  = eventTicketDetails[matchSeatTicketDetail.EventTicketDetailId];
                    var additionalInfo     = _eventTicketAttributeRepository.GetByEventTicketDetailId(eventTicketDetail.Id).AdditionalInfo;
                    var value              = JsonConvert.DeserializeObject <TicketValue>(additionalInfo).value;
                    var ticketCategoryId   = eventTicketDetail.TicketCategoryId;
                    var ticketCategoryName = _ticketCategoryRepository.Get((int)ticketCategoryId).Name.ToString();
                    var currencyId         = transaction.CurrencyId;
                    var transactionUTC     = transaction.CreatedUtc;
                    var currencyCode       = _currencyTypeRepository.GetById(currencyId).Code.ToString();
                    var userAltId          = transaction.CreatedBy;
                    var userId             = _userRepository.GetByAltId(userAltId).Id;
                    var userAddressDetail  = _userAddressDetailRepository.GetByUser(userId);
                    var zipcodeId          = userAddressDetail != null ? userAddressDetail.Zipcode : 9;
                    var postalcode         = _zipcodeRepository.Get(zipcodeId).Postalcode;

                    var barcodeDetailsContainer = new BarcodeDetailsContainer()
                    {
                        AltId            = (System.Guid)matchSeatTicketDetail.AltId,
                        BarcodeNumber    = matchSeatTicketDetail.BarcodeNumber,
                        CurrencyCode     = currencyCode,
                        TicketCategoryId = ticketCategoryId,
                        TicketCategory   = ticketCategoryName,
                        Value            = value,
                        Postalcode       = postalcode,
                        IsConsumed       = matchSeatTicketDetail.IsConsumed,
                        ConsumedDateTime = matchSeatTicketDetail.ConsumedDateTime,
                        TransactionUTC   = transactionUTC,
                    };
                    return(new BarcodeQueryResult
                    {
                        BarcodeDetailsContainer = barcodeDetailsContainer,
                        IsValid = true
                    });
                }

                var offlineBarcodeDetail = _offlineBarcodeDetailRepository.GetByBarcodeNumberAndEventTicketDetailIds(query.BarcodeNumber, eventTicketDetails.Keys);
                if (offlineBarcodeDetail != null)
                {
                    var ticketCategoryId = _eventTicketDetailRepository.Get(offlineBarcodeDetail.EventTicketDetailId)
                                           .TicketCategoryId;
                    var ticketCategoryName = _ticketCategoryRepository.Get((int)ticketCategoryId).Name;
                    var currencyCode       = _currencyTypeRepository.GetById(offlineBarcodeDetail.CurrencyId).Code;

                    var barcodeDetailsContainer = new BarcodeDetailsContainer
                    {
                        AltId            = offlineBarcodeDetail.AltId,
                        BarcodeNumber    = offlineBarcodeDetail.BarcodeNumber,
                        CurrencyCode     = currencyCode,
                        TicketCategoryId = ticketCategoryId,
                        TicketCategory   = ticketCategoryName,
                        Value            = offlineBarcodeDetail.Price,
                        Postalcode       = "",
                        IsConsumed       = offlineBarcodeDetail.IsConsumed,
                        ConsumedDateTime = offlineBarcodeDetail.ConsumedDateTime,
                    };
                    return(new BarcodeQueryResult
                    {
                        BarcodeDetailsContainer = barcodeDetailsContainer,
                        IsValid = true
                    });
                }
            }
            catch (Exception ex)
            {
                _logger.Log(Logging.Enums.LogCategory.Error, ex);
            }

            return(new BarcodeQueryResult
            {
                BarcodeDetailsContainer = null,
                IsValid = false
            });
        }
        public List <PAHDetail> GetPAHDetails(long transactionId)
        {
            var transactionDetail = _transactionDetailRepository.GetByTransactionId(transactionId);

            try
            {
                var feelBarcodeMapping = _feelBarcodeMappingRepository.GetByTransactionDetailIds(transactionDetail.Select(s => s.Id)).ToList();
                List <PAHDetail>           listPAHDetails          = new List <PAHDetail>();
                List <CategoryWiseTickets> categoryWiseTicketsList = new List <CategoryWiseTickets>();
                long[] transactionDetailIds = new long[feelBarcodeMapping.Count];
                if (feelBarcodeMapping.Count() > 0)
                {
                    int i = 0, totalTickets = 0; decimal grptotalPrice = 0;
                    foreach (FeelBarcodeMapping currentBarcode in feelBarcodeMapping)
                    {
                        i++;
                        PAHDetail           pAHDetail           = new PAHDetail();
                        CategoryWiseTickets categoryWiseTickets = new CategoryWiseTickets();
                        var currentTransaction = _transactionRepository.Get(transactionId);
                        // check for hoho timeslot
                        var citySightSeeingTransaction = _citySightSeeingTransactionDetailRepository.GetByTransactionId(currentTransaction.Id);
                        if (citySightSeeingTransaction.HasTimeSlot && citySightSeeingTransaction.TimeSlot != null)
                        {
                            var formatTimeSlot = citySightSeeingTransaction.TimeSlot.Split(":");
                            pAHDetail.TimeSlot = formatTimeSlot[0] + ":" + formatTimeSlot[1];
                        }
                        var currentTransactionDetail     = _transactionDetailRepository.Get(currentBarcode.TransactionDetailId);
                        var currentEventTicketAttributes = _eventTicketAttributeRepository.Get((int)currentTransactionDetail.EventTicketAttributeId);
                        var currentEventTicketDetail     = _eventTicketDetailRepository.Get(currentEventTicketAttributes.EventTicketDetailId);
                        var currentTicketCategory        = _ticketCategoryRepository.Get((int)currentEventTicketDetail.TicketCategoryId);
                        var currentEventDetails          = _eventDetailRepository.Get(currentEventTicketDetail.EventDetailId);
                        var curretVenue = _venueRepository.Get(currentEventDetails.VenueId);
                        var currentCity = _cityRepository.Get(curretVenue.CityId);
                        var currentstate = _stateRepository.Get(currentCity.StateId);
                        var currentcountry = _countryRepository.Get(currentstate.CountryId);
                        var currentEvent = _eventRepository.Get(currentEventDetails.EventId);
                        var currentCurrencyType = _currencyTypeRepository.Get(currentEventTicketAttributes.CurrencyId);
                        var flag = true; var ticketCatName = currentTicketCategory.Name;
                        grptotalPrice += currentEventTicketAttributes.Price;
                        totalTickets  += currentTransactionDetail.TotalTickets;
                        categoryWiseTickets.CategoryName = currentTicketCategory.Name;
                        categoryWiseTickets.TotalTickets = currentTransactionDetail.TotalTickets;
                        if (currentBarcode.GroupCodeExist)
                        {
                            flag = false;
                            if (!transactionDetailIds.Contains(currentBarcode.TransactionDetailId))
                            {
                                transactionDetailIds[i - 1] = currentBarcode.TransactionDetailId;
                                categoryWiseTicketsList.Add(categoryWiseTickets);
                            }
                        }
                        if (currentBarcode.GroupCodeExist && feelBarcodeMapping.Count == i)
                        {
                            flag          = true;
                            ticketCatName = "Group";
                        }
                        if (flag)
                        {
                            pAHDetail.EventId             = currentEvent.Id;
                            pAHDetail.EventName           = currentEvent.Name;
                            pAHDetail.EventStartTime      = (DateTime)currentTransactionDetail.VisitDate;
                            pAHDetail.EventsourceId       = (long)(EventSource)Enum.Parse(typeof(EventSource), currentEvent.EventSourceId.ToString());
                            pAHDetail.Price               = currentBarcode.GroupCodeExist ? grptotalPrice : currentEventTicketAttributes.Price;
                            pAHDetail.TicketCategoryName  = ticketCatName;
                            pAHDetail.TotalTickets        = currentBarcode.GroupCodeExist ? totalTickets : currentTransactionDetail.TotalTickets;
                            pAHDetail.EventDetailsName    = currentEventDetails.Name;
                            pAHDetail.VenueId             = curretVenue.Id;
                            pAHDetail.VenueName           = curretVenue.Name;
                            pAHDetail.CityName            = currentCity.Name;
                            pAHDetail.CountryName         = currentcountry.Name;
                            pAHDetail.BarcodeNumber       = currentBarcode.Barcode;
                            pAHDetail.CurrencyName        = currentCurrencyType.Code;
                            pAHDetail.EventDeatilId       = currentEventDetails.Id;
                            pAHDetail.FirstName           = currentTransaction.FirstName;
                            pAHDetail.LastName            = currentTransaction.LastName;
                            pAHDetail.EmailId             = currentTransaction.EmailId;
                            pAHDetail.PhoneNumber         = currentTransaction.PhoneNumber;
                            pAHDetail.TransactionId       = currentTransaction.Id;
                            pAHDetail.CategoryWiseTickets = AutoMapper.Mapper.Map <List <CategoryWiseTickets> >(categoryWiseTicketsList);
                            listPAHDetails.Add(pAHDetail);
                        }
                    }
                    return(listPAHDetails);
                }
                else
                {
                    return(listPAHDetails);
                }
            }
            catch (Exception ex)
            {
                _logger.Log(Logging.Enums.LogCategory.Error, new Exception(ex.Message));
                return(null);
            }
        }
Beispiel #4
0
        public GetPlaceInventoryQueryResult Handle(GetPlaceInventoryQuery query)
        {
            try
            {
                var eventData  = _eventRepository.GetByAltId(query.PlaceAltId);
                var eventModel = AutoMapper.Mapper.Map <FIL.Contracts.Models.Event>(eventData);

                List <string> TicketValidityTypes = new List <string>();
                List <string> DeliveryTypes       = new List <string>();

                foreach (FIL.Contracts.Enums.TicketValidityTypes ticketValidity in Enum.GetValues(typeof(FIL.Contracts.Enums.TicketValidityTypes)))
                {
                    TicketValidityTypes.Add(ticketValidity.ToString());
                }

                foreach (FIL.Contracts.Enums.DeliveryTypes DeliveryType in Enum.GetValues(typeof(FIL.Contracts.Enums.DeliveryTypes)))
                {
                    DeliveryTypes.Add(DeliveryType.ToString());
                }

                var eventDetail      = _eventDetailRepository.GetAllByEventId(eventData.Id);
                var eventDetailModel = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.EventDetail> >(eventDetail).Where(s => s.IsEnabled == true).ToList();

                var eventTicketDetils = _eventTicketDetail.GetByEventDetailId(eventDetail.ElementAt(0).Id).Where(s => s.IsEnabled == true);
                var eventAttribute    = _eventAttributeRepository.GetByEventDetailId(eventDetail.FirstOrDefault().Id);
                var EventTicketDetailTicketCategoryTypeMappingDataModel = _eventTicketDetailTicketCategoryTypeMappingRepository.GetByEventTicketDetails(eventTicketDetils.Select(s => s.Id).ToList()).Where(s => s.IsEnabled == true);
                var EventTicketDetailTicketCategoryTypeMappingModel     = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.EventTicketDetailTicketCategoryTypeMapping> >(EventTicketDetailTicketCategoryTypeMappingDataModel);

                var ticketCategories = _ticketCategoryRepository.GetByTicketCategoryIds(eventTicketDetils.Select(s => s.TicketCategoryId)).Where(s => s.IsEnabled == true);

                var placeCustomerDocumentTypes     = _placeCustomerDocumentTypeMappingRepository.GetAllByEventId(eventData.Id);
                var placeCustomerDocumentTypeModel = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.PlaceCustomerDocumentTypeMapping> >(placeCustomerDocumentTypes);

                var placeTicketRedemptionDetails     = _placeTicketRedemptionDetailRepository.GetAllByEventDetailIds(eventDetail.Select(s => s.Id));
                var placeTicketRedemptionDetailModel = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.PlaceTicketRedemptionDetail> >(placeTicketRedemptionDetails);

                var placeDeliveryTypes      = _eventDeliveryTypeDetailRepository.GetByEventDetailId(eventDetail.ElementAt(0).Id);
                var placeDeliveryTypesModel = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.EventDeliveryTypeDetail> >(placeDeliveryTypes);

                var customerDoumentType      = _customerDocumentTypeRepository.GetAll();
                var customerDoumentTypeModel = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.CustomerDocumentType> >(customerDoumentType);

                var placeHolidayDates      = _placeHolidydates.GetAllByEventId(eventData.Id);
                var placeHolidayDatesModel = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.PlaceHolidayDate> >(placeHolidayDates);

                var placeWeekOffs      = _placeWeekOffRepository.GetAllByEventId(eventData.Id);
                var placeWeekOffsModel = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.PlaceWeekOff> >(placeWeekOffs);

                var customerInformationMapping      = _customerInformationRepository.GetAll();
                var customerInformationMappingModel = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.CustomerInformation> >(customerInformationMapping);

                var eventCustomerInformationMapping = _eventCustomerInformationMappingRepository.GetAllByEventID(eventModel.Id).ToList();
                List <FIL.Contracts.Models.EventCustomerInformationMapping> eventCustomerInformationMappingModel = new List <Contracts.Models.EventCustomerInformationMapping>();;
                if (eventCustomerInformationMapping.Count() > 0)
                {
                    eventCustomerInformationMappingModel = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.EventCustomerInformationMapping> >(eventCustomerInformationMapping);
                }
                List <FIL.Contracts.DataModels.EventTicketDetail> etdList = new List <FIL.Contracts.DataModels.EventTicketDetail>();

                foreach (FIL.Contracts.DataModels.EventTicketDetail currentTicketCat in eventTicketDetils.ToList())
                { /*--------------- Add those ETD whose eventticketdetail and ETA exists */
                    var etaData = _eventTicketAttribute.GetByEventTicketDetailIdFeelAdmin(currentTicketCat.Id);
                    if (etaData != null)
                    {
                        etdList.Add(currentTicketCat);
                    }
                }

                var ticketCategoryContainer = etdList.Select(td =>
                {
                    try
                    {
                        var ticketDetailModel             = AutoMapper.Mapper.Map <FIL.Contracts.Models.EventTicketDetail>(td);
                        var ticketCategory                = _ticketCategoryRepository.Get((int)td.TicketCategoryId);
                        var ticketCategoryModel           = AutoMapper.Mapper.Map <FIL.Contracts.Models.TicketCategory>(ticketCategory);
                        var eventTicketAttributes         = _eventTicketAttribute.GetByEventTicketDetailIdFeelAdmin(td.Id);
                        var eventTicketAttributeModel     = AutoMapper.Mapper.Map <FIL.Contracts.Models.EventTicketAttribute>(eventTicketAttributes);
                        var TicketCategoryTypeTypeMapping = _eventTicketDetailTicketCategoryTypeMappingRepository.GetByEventTicketDetail(td.Id);
                        var ticketFeeDetail               = _ticketFeeDetailRepository.GetAllByEventTicketAttributeId(eventTicketAttributeModel.Id);
                        var ticketFeeDetailModel          = AutoMapper.Mapper.Map <List <FIL.Contracts.Models.TicketFeeDetail> >(ticketFeeDetail);

                        return(new TicketCategoryInfo
                        {
                            TicketCategory = ticketCategoryModel,
                            EventTicketAttribute = eventTicketAttributeModel,
                            EventTicketDetail = ticketDetailModel,
                            TicketCategorySubTypeId = (TicketCategoryTypeTypeMapping != null ? TicketCategoryTypeTypeMapping.TicketCategorySubTypeId : 1),
                            TicketCategoryTypeId = (TicketCategoryTypeTypeMapping != null ? TicketCategoryTypeTypeMapping.TicketCategoryTypeId : 1),
                            TicketFeeDetails = ticketFeeDetailModel
                        });
                    }
                    catch (Exception e)
                    {
                        return(new TicketCategoryInfo
                        {
                        });
                    }
                }).ToList();

                var data = _calendarProvider.GetCalendarData(eventData.Id);

                return(new GetPlaceInventoryQueryResult
                {
                    Event = eventModel,
                    EventDetails = eventDetailModel,
                    TicketCategoryContainer = ticketCategoryContainer,
                    PlaceCustomerDocumentTypeMappings = placeCustomerDocumentTypeModel,
                    DeliveryTypes = DeliveryTypes,
                    eventDeliveryTypeDetails = placeDeliveryTypesModel,
                    EventTicketDetailTicketCategoryTypeMappings = EventTicketDetailTicketCategoryTypeMappingModel,
                    PlaceTicketRedemptionDetails = placeTicketRedemptionDetailModel,
                    TicketValidityTypes = TicketValidityTypes,
                    CustomerDocumentTypes = customerDoumentTypeModel,
                    PlaceHolidayDates = placeHolidayDatesModel,
                    PlaceWeekOffs = placeWeekOffsModel,
                    CustomerInformations = customerInformationMappingModel,
                    EventCustomerInformationMappings = eventCustomerInformationMappingModel,
                    RegularTimeModel = data.RegularTimeModel,
                    SeasonTimeModel = data.SeasonTimeModel,
                    SpecialDayModel = data.SpecialDayModel,
                    EventAttribute = eventAttribute
                });
            }
            catch (Exception e)
            {
                return(new GetPlaceInventoryQueryResult
                {
                });
            }
        }
Beispiel #5
0
        public async Task <ASIBookingResponse> saveASIData(ASIBooking aSIBooking)
        {
            var            transactionData    = _transactionRepository.Get(aSIBooking.TransactionId);
            var            transactionDetails = _transactionDetailRepository.GetByTransactionId(aSIBooking.TransactionId);
            List <Visitor> visitors           = new List <Visitor>();
            List <ASIHash> aSIHashes          = new List <ASIHash>();
            RootObject     rootObject         = new RootObject();

            foreach (FIL.Contracts.DataModels.TransactionDetail currentTransactionDetail in transactionDetails)
            {
                var clientETAData = aSIBooking.EventTicketAttributeList.Where(s => s.Id == currentTransactionDetail.EventTicketAttributeId && (TicketType)currentTransactionDetail.TicketTypeId == s.TicketType).FirstOrDefault();
                if (clientETAData != null)
                {
                    foreach (FIL.Contracts.Commands.Transaction.GuestUserDetail currentGuestDetail in clientETAData.GuestDetails)
                    {
                        _saveGuestUserProvider.SaveGuestUsers(currentGuestDetail, currentTransactionDetail);
                    }

                    _aSITransactionDetailTimeSlotIdMappingRepository.Save(new FIL.Contracts.DataModels.ASI.ASITransactionDetailTimeSlotIdMapping
                    {
                        EventTimeSlotMappingId = (long)clientETAData.VisitTimeId,
                        TransactionDetailId    = currentTransactionDetail.Id,
                        IsEnabled  = true,
                        CreatedUtc = DateTime.UtcNow,
                        UpdatedUtc = DateTime.UtcNow
                    });

                    _transactionDeliveryDetailRepository.Save(new TransactionDeliveryDetail
                    {
                        TransactionDetailId = currentTransactionDetail.Id,
                        DeliveryTypeId      = DeliveryTypes.PrintAtHome,
                        PickupBy            = 1,
                        SecondaryName       = "Zoonga",
                        SecondaryContact    = "Zoonga",
                        SecondaryEmail      = transactionData.EmailId,
                        PickUpAddress       = "Zoonga"
                    });
                }
            }
            // This is separate loop for API request payload..... I don't think we need to manage data from above loop... Better to keep it separate
            foreach (FIL.Contracts.DataModels.TransactionDetail currentTransactionDetail in transactionDetails)
            {
                var guestData          = _guestDetailRepository.GetByTransactionDetailId(currentTransactionDetail.Id);
                var asiTicketAttribute = aSIBooking.EventTicketAttributeList.Where(s => s.Id == currentTransactionDetail.EventTicketAttributeId).FirstOrDefault();
                if (guestData.Any())
                {
                    var currentETA        = _eventTicketAttributeRepository.Get(currentTransactionDetail.EventTicketAttributeId);
                    var currentETD        = _eventTicketDetailRepository.Get(currentETA.EventTicketDetailId);
                    var currentTc         = _ticketCategoryRepository.Get((int)currentETD.TicketCategoryId);
                    var currentED         = _eventDetailRepository.Get(currentETD.EventDetailId);
                    var currentE          = _eventRepository.Get(currentED.EventId);
                    var asiETableMapping  = _aSIMonumentEventTableMappingRepository.GetByEventId(currentE.Id);
                    var asiMonument       = _aSIMonumentRepository.Get(asiETableMapping.ASIMonumentId);
                    var asiMonumentDetail = _aSIMonumentDetailRepository.GetByNameAndMonumentId(currentED.Name, asiMonument.Id);
                    var asiTimeSlot       = _aSITransactionDetailTimeSlotIdMappingRepository.GetByTransactionDetailId(currentTransactionDetail.Id);
                    var eventTimeSlot     = _eventTimeSlotMappingRepository.Get(asiTimeSlot.EventTimeSlotMappingId);
                    //api.key |[monument.code | optional | date | age | country | amount] |[monument.code | optional | date | age | country | amount] | api.salt
                    foreach (FIL.Contracts.DataModels.GuestDetail currentGuestDetail in guestData)
                    {
                        Visitor     visitor     = new Visitor();
                        ASIHash     aSIHash     = new ASIHash();
                        Identity    indentity   = new Identity();
                        Monument    monument    = new Monument();
                        Nationality nationality = new Nationality();
                        Timeslot    timeslot    = new Timeslot();
                        visitor.Identity          = indentity;
                        visitor.Monument          = monument;
                        visitor.Monument.Timeslot = timeslot;
                        visitor.Nationality       = nationality;
                        var custerDocType = _customerDocumentTypeRepository.Get(currentGuestDetail.CustomerDocumentTypeId);
                        visitor.Age                  = Convert.ToInt32(currentGuestDetail.Age);
                        visitor.VisitorId            = currentGuestDetail.Id.ToString();
                        visitor.Amount               = currentTransactionDetail.PricePerTicket;
                        visitor.Gender               = currentGuestDetail.GenderId.ToString();
                        visitor.Name                 = currentGuestDetail.FirstName + " " + currentGuestDetail.LastName;
                        visitor.Date                 = ((System.DateTime)currentTransactionDetail.VisitDate).ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'");
                        visitor.Identity.Type        = custerDocType.DocumentType;
                        visitor.Identity.No          = currentGuestDetail.DocumentNumber;
                        visitor.Monument.Code        = "TAJ";
                        visitor.Monument.Optional    = asiMonumentDetail.IsOptional;
                        visitor.Monument.Main        = true;
                        visitor.Monument.Timeslot.Id = eventTimeSlot.TimeSlotId;
                        visitor.Nationality.Group    = currentTc.Name;
                        visitor.Nationality.Country  = asiTicketAttribute == null ? "India" : asiTicketAttribute.ASIUserSelectedCountry;
                        visitors.Add(visitor);

                        aSIHash.Code           = asiMonument.Code;
                        aSIHash.IsOptional     = asiMonumentDetail.IsOptional;
                        aSIHash.Date           = (System.DateTime)currentTransactionDetail.VisitDate;
                        aSIHash.Nationality    = currentTc.Name;
                        aSIHash.Age            = Convert.ToInt32(currentGuestDetail.Age);
                        aSIHash.Amount         = currentTransactionDetail.PricePerTicket;
                        aSIHash.IdentityType   = "Passport";
                        aSIHash.IdentityNumber = "SADFG";
                        aSIHash.VisitorId      = currentGuestDetail.Id.ToString();
                        aSIHashes.Add(aSIHash);
                    }
                }
            }

            var ticketHash = "";

            foreach (FIL.Contracts.Models.ASI.ASIHash currentHash in aSIHashes)
            {
                TimeZoneInfo INDIAN_ZONE;
                try
                {
                    INDIAN_ZONE = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
                }
                catch (Exception e)
                {
                    INDIAN_ZONE = TimeZoneInfo.FindSystemTimeZoneById("Asia/Kolkata");
                }
                DateTime indianTime = TimeZoneInfo.ConvertTimeFromUtc(currentHash.Date, INDIAN_ZONE);
                var      time       = indianTime.ToUniversalTime().ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'");
                ticketHash = ticketHash + "[" + currentHash.Code + "|" + (!currentHash.IsOptional).ToString().ToLower() + "|" + currentHash.IsOptional.ToString().ToLower() + "|" + indianTime.ToString("yyyy-MM-dd") + "|" + currentHash.Age + "|" + currentHash.Nationality + "|" + currentHash.Amount.ToString("0.00") + "]" + "|";
                //ticketHash = ticketHash + "[" + "TAJ" + "|" + time + "|" + currentHash.IdentityType + "|" + currentHash.IdentityNumber + "|" + currentHash.Age + "|" + currentHash.Nationality + "|" + currentHash.Amount.ToString("0.00") + "|" + currentHash.VisitorId + "]" + "|";
            }
            var bookingHashRequestData = _settings.GetConfigSetting <string>(SettingKeys.Integration.ASI.APIKey) + "|" + ticketHash + _settings.GetConfigSetting <string>(SettingKeys.Integration.ASI.APISalt);
            var bookingHash            = GenerateSHA512Hash(bookingHashRequestData);

            rootObject.TransactionId = aSIBooking.TransactionId.ToString();
            rootObject.Hash          = bookingHash.ToLower();
            rootObject.Visitors      = visitors;
            rootObject.Email         = transactionData.EmailId == "*****@*****.**" ? transactionData.PhoneNumber : transactionData.EmailId;
            UserCardDetail userCardDetail = _userCardDetailRepository.GetByUserCardNumber(string.Empty, aSIBooking.UserId);

            if (userCardDetail == null)
            {
                UserCardDetail obj = new UserCardDetail
                {
                    UserId      = aSIBooking.UserId,
                    AltId       = new Guid(),
                    NameOnCard  = string.Empty,
                    CardNumber  = string.Empty,
                    ExpiryMonth = 12,
                    ExpiryYear  = 2020,
                    CardTypeId  = CardType.None
                };
                userCardDetail = _userCardDetailRepository.Save(obj);
            }

            _transactionPaymentDetailRepository.Save(new TransactionPaymentDetail // Create transaction payment request before calling booking POST API request...
            {
                TransactionId    = aSIBooking.TransactionId,
                PaymentOptionId  = PaymentOptions.None,
                PaymentGatewayId = PaymentGateway.Payu,
                UserCardDetailId = userCardDetail.Id,
                RequestType      = "Charge Posting",
                Amount           = transactionData.NetTicketAmount.ToString(),
                PayConfNumber    = "",
                PaymentDetail    = "{\"Request\":" + Newtonsoft.Json.JsonConvert.SerializeObject(rootObject) + "{\"hashparameter\":" + bookingHashRequestData + "}}",
            });
            var baseAddress = _settings.GetConfigSetting <string>(SettingKeys.Integration.ASI.IntegrationRoot).ToString() + "" + _settings.GetConfigSetting <string>(SettingKeys.Integration.ASI.APIKey).ToString();

            return(new ASIBookingResponse
            {
                RootObject = rootObject,
                ReturnUrl = baseAddress
            });
        }
        protected override async Task Handle(SaveEventScheduleCommand command)
        {
            foreach (var eventDetail in command.SubEventList)
            {
                var eventDetailData = new EventDetail();
                if (eventDetail.id == 0) // check for create or edit insert if 0
                {
                    eventDetailData = new FIL.Contracts.DataModels.EventDetail
                    {
                        Name          = eventDetail.name,
                        EventId       = eventDetail.eventId,
                        AltId         = Guid.NewGuid(),
                        VenueId       = eventDetail.venueId,
                        MetaDetails   = null,
                        Description   = eventDetail.Description,
                        GroupId       = 1,
                        StartDateTime = DateTime.Parse(eventDetail.startDateTime),
                        EndDateTime   = DateTime.Parse(eventDetail.endDateTime),
                        IsEnabled     = false,
                        CreatedUtc    = DateTime.UtcNow,
                        ModifiedBy    = command.userAltId
                    };
                    _eventDetailRepository.Save(eventDetailData);
                }
                else // update sub event
                {
                    eventDetailData               = _eventDetailRepository.Get(eventDetail.id);
                    eventDetailData.Name          = eventDetail.name;
                    eventDetailData.EventId       = eventDetail.eventId;
                    eventDetailData.VenueId       = eventDetail.venueId;
                    eventDetailData.Description   = eventDetail.Description;
                    eventDetailData.StartDateTime = DateTime.Parse(eventDetail.startDateTime);
                    eventDetailData.EndDateTime   = DateTime.Parse(eventDetail.endDateTime);
                    eventDetailData.ModifiedBy    = command.userAltId;
                    _eventDetailRepository.Save(eventDetailData);
                }

                //check for existing delivery type details
                var deliveryTypeData = _eventDeliveryTypeDetailRepository.GetByEventDetailId(eventDetailData.Id);
                if (deliveryTypeData.Count() > 0)
                {
                    foreach (var newDeliveryType in deliveryTypeData)
                    {
                        //update existing delivery type details
                        if (Convert.ToInt16(newDeliveryType.DeliveryTypeId) != command.DeliveryValue)
                        {
                            var deliveryValue = _eventDeliveryTypeDetailRepository.Get(newDeliveryType.Id);
                            deliveryValue.DeliveryTypeId = (DeliveryTypes)command.DeliveryValue;
                            _eventDeliveryTypeDetailRepository.Save(deliveryValue);
                        }
                    }
                }
                else // insert new deliveryType
                {
                    var deliveryType = new FIL.Contracts.DataModels.EventDeliveryTypeDetail
                    {
                        EventDetailId  = eventDetailData.Id,
                        DeliveryTypeId = (DeliveryTypes)command.DeliveryValue,
                        Notes          = "<p><strong>Delivery<br /></strong>Ticket packages are shipped to your preferred address (signature upon receival required), or are arranged for a secure pickup location at or near the circuit.</p>",
                        EndDate        = DateTime.UtcNow,
                        IsEnabled      = true,
                        CreatedUtc     = DateTime.UtcNow,
                        ModifiedBy     = command.userAltId,
                    };
                    _eventDeliveryTypeDetailRepository.Save(deliveryType);
                }
                var matchAttributeData = _matchAttributeRepository.GetByEventDetailId(eventDetail.id);
                if (matchAttributeData.Count() > 0)
                {
                    foreach (var oldMatchAttribute in matchAttributeData)
                    {
                        foreach (var newMatchAttribute in eventDetail.matches)
                        {
                            if (oldMatchAttribute.Id == newMatchAttribute.id)
                            {
                                var updatedMatchAttribute = _matchAttributeRepository.Get(newMatchAttribute.id);
                                updatedMatchAttribute.TeamA          = newMatchAttribute.teamA;
                                updatedMatchAttribute.TeamB          = newMatchAttribute.teamB;
                                updatedMatchAttribute.MatchNo        = newMatchAttribute.matchNo;
                                updatedMatchAttribute.MatchDay       = newMatchAttribute.matchDay;
                                updatedMatchAttribute.MatchStartTime = DateTime.Parse(newMatchAttribute.startDateTime);
                                _matchAttributeRepository.Save(updatedMatchAttribute);
                            }
                        }
                    }
                }
                else
                {
                    //check for not null
                    if (eventDetail.matches.Count > 0)
                    {
                        foreach (var match in eventDetail.matches)
                        {
                            //check for if team is exits if not insert new
                            var teamA = match.teamA != 0 ? _teamRepository.Get(match.teamA) :
                                        _teamRepository.Save(
                                new Team
                            {
                                Name        = match.teamAName,
                                AltId       = Guid.NewGuid(),
                                IsEnabled   = true,
                                Description = "",
                                CreatedUtc  = DateTime.UtcNow,
                                UpdatedUtc  = DateTime.UtcNow,
                                CreatedBy   = command.userAltId,
                                UpdatedBy   = command.userAltId
                            }
                                );

                            var teamB = match.teamB != 0 ? _teamRepository.Get(match.teamB) :
                                        _teamRepository.Save(
                                new Team
                            {
                                Name        = match.teamBName,
                                AltId       = Guid.NewGuid(),
                                IsEnabled   = true,
                                Description = "",
                                CreatedUtc  = DateTime.UtcNow,
                                UpdatedUtc  = DateTime.UtcNow,
                                CreatedBy   = command.userAltId,
                                UpdatedBy   = command.userAltId
                            }
                                );

                            var matchAttribute = new FIL.Contracts.DataModels.MatchAttribute
                            {
                                EventDetailId  = eventDetailData.Id,
                                TeamA          = teamA.Id,
                                TeamB          = teamB.Id,
                                MatchNo        = match.matchNo,
                                MatchDay       = match.matchDay,
                                IsEnabled      = true,
                                MatchStartTime = DateTime.Parse(match.startDateTime),
                                CreatedUtc     = DateTime.UtcNow,
                                CreatedBy      = command.userAltId,
                                ModifiedBy     = command.userAltId
                            };
                            _matchAttributeRepository.Save(matchAttribute);
                        }
                    }
                }

                var TicketDetailData = _eventTicketDetailRepository.GetByEventDetailId(eventDetail.id);
                if (TicketDetailData.Count() > 0)
                {
                    foreach (var oldTicketCategory in TicketDetailData)
                    {
                        var newEventTicketDetail = eventDetail.ticketCategories.Where(s => s.id == oldTicketCategory.Id).FirstOrDefault();
                        if (newEventTicketDetail != null)
                        {
                            //update existing eventTicketDetail
                            var updatedEventTicketDetail = _eventTicketDetailRepository.Get(newEventTicketDetail.id);
                            updatedEventTicketDetail.TicketCategoryId = newEventTicketDetail.ticketCategoryId;
                            _eventTicketDetailRepository.Save(updatedEventTicketDetail);

                            //update event ticket attributes
                            var updatedTicketAttibutesData = _eventTicketAttributeRepository.GetByEventTicketDetailId(updatedEventTicketDetail.Id);
                            updatedTicketAttibutesData.AvailableTicketForSale = newEventTicketDetail.capacity;
                            updatedTicketAttibutesData.RemainingTicketForSale = newEventTicketDetail.capacity;
                            updatedTicketAttibutesData.Price           = newEventTicketDetail.price;
                            updatedTicketAttibutesData.LocalPrice      = newEventTicketDetail.price;
                            updatedTicketAttibutesData.CurrencyId      = newEventTicketDetail.currencyId;
                            updatedTicketAttibutesData.LocalCurrencyId = newEventTicketDetail.currencyId;
                            _eventTicketAttributeRepository.Save(updatedTicketAttibutesData);

                            //get exisiting ticket fee details
                            var oldticketFeeDetailData = _ticketFeeDetailRepository.GetAllByEventTicketAttributeId(updatedTicketAttibutesData.Id).ToList();

                            foreach (var feeType in command.FeeTypes)
                            {
                                if (feeType.id == 0)
                                {
                                    var ticketFeeDetailData = new FIL.Contracts.DataModels.TicketFeeDetail
                                    {
                                        EventTicketAttributeId = updatedTicketAttibutesData.Id,
                                        FeeId       = (Int16)feeType.feeId,
                                        DisplayName = feeType.displayName,
                                        ValueTypeId = (Int16)feeType.valueTypeId,
                                        Value       = feeType.value,
                                        IsEnabled   = true,
                                        CreatedUtc  = DateTime.UtcNow,
                                        CreatedBy   = command.userAltId
                                    };
                                    _ticketFeeDetailRepository.Save(ticketFeeDetailData);
                                }
                            }

                            if (oldticketFeeDetailData.Count() > 0)
                            {
                                foreach (var oldTicketFeeDetail in oldticketFeeDetailData)
                                {
                                    var newTicketFeeDetail = command.FeeTypes.Where(s => s.id == oldTicketFeeDetail.Id).FirstOrDefault();

                                    if (newTicketFeeDetail != null)
                                    {
                                        var updatedTicketFeeDetail = _ticketFeeDetailRepository.Get(oldTicketFeeDetail.Id);
                                        updatedTicketFeeDetail.FeeId       = Convert.ToInt16(newTicketFeeDetail.feeId);
                                        updatedTicketFeeDetail.ValueTypeId = Convert.ToInt16(newTicketFeeDetail.valueTypeId);
                                        updatedTicketFeeDetail.Value       = newTicketFeeDetail.value;
                                        _ticketFeeDetailRepository.Save(updatedTicketFeeDetail);
                                    }
                                    else
                                    {
                                        var updatedTicketFeeDetail = _ticketFeeDetailRepository.Get(oldTicketFeeDetail.Id);
                                        updatedTicketFeeDetail.IsEnabled = false;
                                        _ticketFeeDetailRepository.Save(updatedTicketFeeDetail);
                                    }
                                }
                            }
                        }
                        else
                        {
                            var updatedEventTicketDetail = _eventTicketDetailRepository.Get(oldTicketCategory.Id);
                            updatedEventTicketDetail.IsEnabled = false;
                            _eventTicketDetailRepository.Save(updatedEventTicketDetail);
                        }
                    }
                }

                if (eventDetail.ticketCategories.Count > 0)
                {
                    foreach (var eventTicketDetail in eventDetail.ticketCategories)
                    {
                        if (eventTicketDetail.id == 0) // insert new category
                        {
                            //check for if ticket category is exits if not insert new
                            var ticketCategory = eventTicketDetail.ticketCategoryId != 0 ? _ticketCategoryRepository.Get(eventTicketDetail.ticketCategoryId) :
                                                 _ticketCategoryRepository.Save(
                                new TicketCategory
                            {
                                Name       = eventTicketDetail.ticketCategoryName,
                                IsEnabled  = true,
                                CreatedUtc = DateTime.UtcNow,
                                UpdatedUtc = DateTime.UtcNow,
                                CreatedBy  = command.userAltId,
                                UpdatedBy  = command.userAltId
                            }
                                );
                            //insert new ticket detail data
                            var eventTicketDetailData = new FIL.Contracts.DataModels.EventTicketDetail
                            {
                                EventDetailId    = eventDetailData.Id,
                                TicketCategoryId = ticketCategory.Id,
                                IsEnabled        = true,
                                CreatedUtc       = DateTime.UtcNow,
                                CreatedBy        = command.userAltId,
                                ModifiedBy       = command.userAltId,
                                IsBOEnabled      = false
                            };
                            _eventTicketDetailRepository.Save(eventTicketDetailData);

                            //save event ticket attributes
                            var eventTicketAttibutesData = new FIL.Contracts.DataModels.EventTicketAttribute
                            {
                                EventTicketDetailId    = eventTicketDetailData.Id,
                                CurrencyId             = eventTicketDetail.currencyId,
                                TicketTypeId           = FIL.Contracts.Enums.TicketType.Adult,
                                ChannelId              = FIL.Contracts.Enums.Channels.Website,
                                AvailableTicketForSale = eventTicketDetail.capacity,
                                RemainingTicketForSale = eventTicketDetail.capacity,
                                Price                      = eventTicketDetail.price,
                                LocalPrice                 = eventTicketDetail.price,
                                CreatedUtc                 = DateTime.UtcNow,
                                CreatedBy                  = command.userAltId,
                                IsEnabled                  = true,
                                IsEMIApplicable            = false,
                                IsInternationalCardAllowed = false,
                                IsSeatSelection            = false,
                                ViewFromStand              = "",
                                TicketCategoryDescription  = "",
                                LocalCurrencyId            = eventTicketDetail.currencyId,
                                SalesStartDateTime         = DateTime.UtcNow,
                                SalesEndDatetime           = DateTime.UtcNow,
                            };
                            _eventTicketAttributeRepository.Save(eventTicketAttibutesData);

                            if (command.FeeTypes.Count > 0)
                            {
                                foreach (var feeType in command.FeeTypes)
                                {
                                    //save ticket fee details
                                    var ticketFeeDetailData = new FIL.Contracts.DataModels.TicketFeeDetail
                                    {
                                        EventTicketAttributeId = eventTicketAttibutesData.Id,
                                        FeeId       = (Int16)feeType.feeId,
                                        DisplayName = feeType.displayName,
                                        ValueTypeId = (Int16)feeType.valueTypeId,
                                        Value       = feeType.value,
                                        IsEnabled   = true,
                                        CreatedUtc  = DateTime.UtcNow,
                                        CreatedBy   = command.userAltId
                                    };
                                    _ticketFeeDetailRepository.Save(ticketFeeDetailData);
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #7
0
        public CheckoutCommandResult SaveTransaction(CheckoutCommand checkoutCommand, IEnumerable <Contracts.Models.EventTicketAttribute> eventTicketAttributeModel, FIL.Contracts.DataModels.User user)
        {
            try
            {
                var isPaymentBypass = false;
                var StripeAccount   = FIL.Contracts.Enums.StripeAccount.None;
                List <TransactionDetail> transactionDetailList             = new List <TransactionDetail>();
                List <FIL.Contracts.Models.CartItemModel> lstEventDetailId = new List <FIL.Contracts.Models.CartItemModel>();
                FIL.Contracts.DataModels.Transaction      transaction      = new FIL.Contracts.DataModels.Transaction();

                decimal grossTicketAmount = 0;
                long    eventDetailId = 0, ticketCategoryId = 0;
                decimal netTicketAmount     = 0;
                decimal totalDiscountAmount = 0;

                if (checkoutCommand.IsASI == null)
                {
                    checkoutCommand.IsASI = false;
                }

                var allETD = _eventTicketDetailRepository.GetByEventTicketDetailsIds(eventTicketAttributeModel.Select(s => s.EventTicketDetailId).Distinct()).Distinct();
                var allED  = _eventDetailRepository.GetByIds(allETD.Select(s => s.EventDetailId).Distinct()).Distinct();
                foreach (Contracts.Commands.Transaction.EventTicketAttribute ticketAttributes in checkoutCommand.EventTicketAttributeList)
                {
                    var     currentTA = ticketAttributes;
                    var     transactionType = checkoutCommand.IsQrTransaction ? TransactionType.QRCode : checkoutCommand.TransactionType == TransactionType.Itinerary ? TransactionType.Itinerary : ticketAttributes.TicketType == TicketType.SeasonPackage ? TransactionType.Season : ticketAttributes.TransactionType == TransactionType.LiveOnline ? TransactionType.LiveOnline : ticketAttributes.TransactionType == TransactionType.AddOns ? TransactionType.AddOns : TransactionType.Regular;
                    decimal discountAmount = 0, donationAmount = 0;
                    if (ticketAttributes.DiscountedPrice > 0)
                    {
                        discountAmount = ticketAttributes.DiscountedPrice;
                    }
                    if (ticketAttributes.DonationAmount != null && ticketAttributes.DonationAmount > 0)
                    {
                        donationAmount = (decimal)ticketAttributes.DonationAmount;
                    }
                    Contracts.Models.EventTicketAttribute checkoutCommandEventTicketAttribute = eventTicketAttributeModel.Where(w => w.Id == ticketAttributes.Id).FirstOrDefault();
                    decimal           pricePerTicket    = checkoutCommandEventTicketAttribute.Price;
                    EventTicketDetail eventTicketDetail = allETD.Where(s => s.Id == checkoutCommandEventTicketAttribute.EventTicketDetailId && s.IsEnabled).FirstOrDefault();
                    if (eventTicketDetail != null)
                    {
                        EventDetail eventDetail = allED.Where(s => s.Id == eventTicketDetail.EventDetailId && s.IsEnabled).FirstOrDefault();
                        if (eventDetail != null)
                        {
                            var visitStartDate = ticketAttributes.VisitDate;
                            var visitEndDate   = ticketAttributes.VisitDate;
                            if (checkoutCommand.TransactionType == TransactionType.Itinerary)
                            {
                                visitStartDate = ticketAttributes.VisitStartTime.Split(":").Count() > 1 ? new DateTime(visitStartDate.Year, visitStartDate.Month, visitStartDate.Day, Convert.ToInt32(ticketAttributes.VisitStartTime.Split(":")[0]), Convert.ToInt32(ticketAttributes.VisitStartTime.Split(":")[1]), 0) : visitStartDate;
                                visitEndDate   = ticketAttributes.VisitEndTime.Split(":").Count() > 1 ? new DateTime(visitEndDate.Year, visitEndDate.Month, visitEndDate.Day, Convert.ToInt32(ticketAttributes.VisitEndTime.Split(":")[0]), Convert.ToInt32(ticketAttributes.VisitEndTime.Split(":")[1]), 0) : visitEndDate;
                            }
                            visitStartDate = visitStartDate < new DateTime(1753, 1, 1) ? DateTime.UtcNow : visitStartDate;
                            visitEndDate   = visitEndDate < new DateTime(1753, 1, 1) ? DateTime.UtcNow : visitEndDate;
                            if ((bool)checkoutCommand.IsASI)
                            {
                                pricePerTicket = ticketAttributes.TicketType == TicketType.Child ? 0 : checkoutCommandEventTicketAttribute.Price;
                            }
                            if (ticketAttributes.OverridedAmount != null && checkoutCommand.IsBSPUpgrade && ticketAttributes.OverridedAmount != 0)
                            {
                                pricePerTicket = (decimal)ticketAttributes.OverridedAmount;
                            }
                            if (ticketAttributes.TicketType == TicketType.SeasonPackage)
                            {
                                eventDetailId = eventTicketDetail.EventDetailId;
                                lstEventDetailId.Add(new FIL.Contracts.Models.CartItemModel {
                                    EventDetailId = eventDetailId
                                });
                                ticketCategoryId = eventTicketDetail.TicketCategoryId;
                                IEnumerable <EventDetail>       seasonEventDetails       = _eventDetailRepository.GetSeasonEventDetails(eventDetail.EventId, eventDetail.VenueId).Where(s => s.IsEnabled == true);
                                IEnumerable <EventTicketDetail> seasonEventTicketDetails = _eventTicketDetailRepository.GetByEventDetailIds(seasonEventDetails.Select(s => s.Id).Distinct()).Where(w => w.TicketCategoryId == eventTicketDetail.TicketCategoryId);
                                List <Contracts.DataModels.EventTicketAttribute> seasonEventTicketAttributes = _eventTicketAttributeRepository.GetByEventTicketDetailIds(seasonEventTicketDetails.Select(s => s.Id).Distinct()).Where(W => W.IsEnabled == true && W.SeasonPackage == true).ToList();
                                var seasonPrice = seasonEventTicketAttributes[0].SeasonPackagePrice;
                                pricePerTicket = seasonPrice / seasonEventTicketAttributes.Count;
                            }
                            else
                            {
                                eventDetailId = eventDetail.Id;
                                lstEventDetailId.Add(new FIL.Contracts.Models.CartItemModel {
                                    EventDetailId = eventTicketDetail.EventDetailId
                                });
                                ticketCategoryId = eventTicketDetail.TicketCategoryId;
                            }

                            if (Convert.ToInt16(ticketAttributes.TotalTickets) <= checkoutCommandEventTicketAttribute.RemainingTicketForSale)
                            {
                                TransactionDetail transactionDetail = new TransactionDetail();
                                transactionDetail.EventTicketAttributeId = ticketAttributes.Id;
                                transactionDetail.TotalTickets           = Convert.ToInt16(ticketAttributes.TotalTickets);
                                transactionDetail.PricePerTicket         = checkoutCommand.TransactionType == TransactionType.Itinerary ? ticketAttributes.Price : pricePerTicket;
                                transactionDetail.DiscountAmount         = discountAmount;
                                transactionDetail.VisitDate       = visitStartDate;
                                transactionDetail.VisitEndDate    = visitEndDate;
                                transactionDetail.TransactionType = transactionType;
                                transactionDetail.TicketTypeId    = checkoutCommand.TransactionType == TransactionType.Itinerary ? (short)(ticketAttributes.IsAdult ? 10 : 2) : (short)(TicketType)ticketAttributes.TicketType;
                                if (checkoutCommand.ReferralId != null)
                                {
                                    var referral = _referralProvider.GetReferral(checkoutCommand.ReferralId, eventDetail.EventId, checkoutCommand.ModifiedBy);
                                    if (referral != null && referral.Id != 0)
                                    {
                                        transactionDetail.ReferralId = referral.Id;
                                    }
                                }
                                if (checkoutCommand.ChannelId == Channels.Feel && checkoutCommand.TransactionType != TransactionType.Itinerary)
                                {
                                    _geoCurrency.UpdateTransactionUpdates(transactionDetail, checkoutCommand.TargetCurrencyCode, checkoutCommandEventTicketAttribute.CurrencyId);
                                }
                                if (donationAmount > 0) // Donation doesn't need the local currency as the amount itself in the local currency
                                {
                                    transactionDetail.PricePerTicket = transactionDetail.PricePerTicket + donationAmount;
                                }
                                netTicketAmount               += ((ticketAttributes.TotalTickets * (decimal)transactionDetail.PricePerTicket) - ((decimal)transactionDetail.DiscountAmount));
                                grossTicketAmount             += ((ticketAttributes.TotalTickets * transactionDetail.PricePerTicket));
                                totalDiscountAmount           += (decimal)transactionDetail.DiscountAmount;
                                transactionDetail.MembershipId = ticketAttributes.MembershipId;
                                transactionDetailList.Add(transactionDetail);
                            }
                            else
                            {
                                EventDetail eventDetails = _eventDetailRepository.Get(eventDetailId);
                                Contracts.DataModels.TicketCategory ticketCategory = _ticketCategoryRepository.Get((int)ticketCategoryId);
                                return(new CheckoutCommandResult
                                {
                                    Id = 0,
                                    Success = false,
                                    EventName = eventDetails.Name,
                                    TicketCategoryName = ticketAttributes.TicketType == TicketType.SeasonPackage ? "Season - " + ticketCategory.Name : ticketCategory.Name,
                                    IsTransactionLimitExceed = false,
                                    IsTicketCategorySoldOut = true
                                });
                            }
                        }
                        else
                        {
                            EventDetail eventDetails = _eventDetailRepository.Get(eventDetailId);
                            Contracts.DataModels.TicketCategory ticketCategory = _ticketCategoryRepository.Get((int)ticketCategoryId);
                            return(new CheckoutCommandResult
                            {
                                Id = 0,
                                Success = false,
                                EventName = eventDetails.Name,
                                TicketCategoryName = ticketAttributes.TicketType == TicketType.SeasonPackage ? "Season - " + ticketCategory.Name : ticketCategory.Name,
                                IsTransactionLimitExceed = false,
                                IsTicketCategorySoldOut = true
                            });
                        }
                    }
                    else
                    {
                        EventDetail eventDetails = _eventDetailRepository.Get(eventDetailId);
                        Contracts.DataModels.TicketCategory ticketCategory = _ticketCategoryRepository.Get((int)ticketCategoryId);
                        return(new CheckoutCommandResult
                        {
                            Id = 0,
                            Success = false,
                            EventName = eventDetails.Name,
                            TicketCategoryName = ticketAttributes.TicketType == TicketType.SeasonPackage ? "Season - " + ticketCategory.Name : ticketCategory.Name,
                            IsTransactionLimitExceed = false,
                            IsTicketCategorySoldOut = true
                        });
                    }
                }
                var intialCurrencyId = eventTicketAttributeModel.Select(s => s.CurrencyId).FirstOrDefault();
                var currencyId       = eventTicketAttributeModel.Select(s => s.CurrencyId).FirstOrDefault();
                if (checkoutCommand.ChannelId == Channels.Feel) // Update the currencyId
                {
                    if (checkoutCommand.TransactionType == TransactionType.Itinerary)
                    {
                        currencyId = _geoCurrency.GetCurrencyID(checkoutCommand.TransactionCurrency).Id;
                    }
                    else
                    {
                        currencyId = _geoCurrency.GetCurrencyID(checkoutCommand.TargetCurrencyCode).Id;
                    }
                }

                /*if (checkoutCommand.ISRasv) // NAB test bed
                 * {
                 * var splitprice = netTicketAmount.ToString("0.00").Split(".");
                 *  var price = splitprice[0] + ".00";
                 * netTicketAmount = Convert.ToDecimal(netTicketAmount);
                 * }*/

                transaction.ChannelId           = checkoutCommand.ChannelId;
                transaction.CurrencyId          = currencyId;
                transaction.TotalTickets        = Convert.ToInt16(checkoutCommand.EventTicketAttributeList.Sum(s => s.TotalTickets));
                transaction.GrossTicketAmount   = grossTicketAmount;
                transaction.NetTicketAmount     = netTicketAmount;
                transaction.DiscountAmount      = totalDiscountAmount;
                transaction.TransactionStatusId = TransactionStatus.UnderPayment;
                transaction.FirstName           = user.FirstName;
                transaction.LastName            = user.LastName;
                transaction.PhoneCode           = user.PhoneCode;
                transaction.PhoneNumber         = user.Email == "*****@*****.**" ? checkoutCommand.GuestUser.PhoneNumber : user.PhoneNumber;
                transaction.EmailId             = user.Email == "*****@*****.**" ? checkoutCommand.GuestUser.PhoneNumber : user.Email;
                transaction.CountryName         = !string.IsNullOrWhiteSpace(user.PhoneCode) ? _countryRepository.GetByPhoneCode(user.PhoneCode).Name : "India";
                transaction.CreatedBy           = user.AltId;
                transaction.CreatedUtc          = DateTime.UtcNow;

                try
                {
                    var ipDetail = _saveIPProvider.SaveIp(checkoutCommand.Ip);
                    if (ipDetail != null && ipDetail.Id > 0)
                    {
                        transaction.IPDetailId = ipDetail.Id;
                    }
                }
                catch (Exception e)
                {
                    _logger.Log(Logging.Enums.LogCategory.Error, e);
                    transaction.IPDetailId = 1;
                }

                transaction.ModifiedBy = user.AltId;
                transaction.AltId      = Guid.NewGuid();
                if (transaction.CurrencyId != 7)
                {
                    transaction.OTP = checkoutCommand.OTPCode;
                }
                if (checkoutCommand.DonationAmount != null && checkoutCommand.DonationAmount != 0)
                {
                    transaction.DonationAmount = checkoutCommand.DonationAmount;
                }

                FIL.Contracts.DataModels.Transaction transactionResult = _transactionRepository.Save(transaction);
                foreach (TransactionDetail transactionDetail in transactionDetailList)
                {
                    transactionDetail.TransactionId = transactionResult.Id;
                    var currentTransactionDetail = _transactionDetailRepository.Save(transactionDetail);
                    FIL.Contracts.DataModels.EventTicketAttribute eventTicketAttribute = AutoMapper.Mapper.Map <FIL.Contracts.DataModels.EventTicketAttribute>(_eventTicketAttributeRepository.Get(transactionDetail.EventTicketAttributeId));
                    FIL.Contracts.DataModels.EventTicketDetail    eventTicketDetail    = AutoMapper.Mapper.Map <FIL.Contracts.DataModels.EventTicketDetail>(_eventTicketDetailRepository.Get(eventTicketAttribute.EventTicketDetailId));
                    if (Convert.ToInt16(transactionDetail.TotalTickets) <= eventTicketAttribute.RemainingTicketForSale)
                    {
                        eventTicketAttribute.RemainingTicketForSale -= transactionDetail.TotalTickets;
                        _eventTicketAttributeRepository.Save(eventTicketAttribute);
                        if (checkoutCommand.ChannelId == Channels.Website)
                        {
                            if (eventTicketDetail.InventoryTypeId == InventoryType.Seated || eventTicketDetail.InventoryTypeId == InventoryType.SeatedWithSeatSelection || eventTicketDetail.InventoryTypeId == InventoryType.NoneSeated)
                            {
                                List <Contracts.Models.TMS.SeatDetail> seatDetail = new List <Contracts.Models.TMS.SeatDetail>();
                                if (checkoutCommand.SeatDetails != null)
                                {
                                    seatDetail = AutoMapper.Mapper.Map <List <Contracts.Models.TMS.SeatDetail> >(checkoutCommand.SeatDetails.Where(w => w.EventTicketDetailId == eventTicketDetail.Id));
                                }
                                else
                                {
                                    seatDetail = null;
                                }
                                var seatBlock = _seatBlockingProvider.BlockSeat(seatDetail, transactionDetail, eventTicketAttribute, eventTicketDetail, user.AltId, Channels.Website);
                                if (!seatBlock.Success && seatBlock.IsSeatSoldOut)
                                {
                                    return(new CheckoutCommandResult
                                    {
                                        Success = false,
                                        Id = 0,
                                        TransactionAltId = Guid.NewGuid(),
                                        IsTransactionLimitExceed = false,
                                        IsTicketCategorySoldOut = false,
                                        IsSeatSoldOut = true
                                    });
                                }
                            }
                        }
                    }
                    else
                    {
                        EventDetail eventDetails = _eventDetailRepository.Get(eventDetailId);
                        Contracts.DataModels.TicketCategory ticketCategory = _ticketCategoryRepository.Get((int)ticketCategoryId);
                        return(new CheckoutCommandResult
                        {
                            Id = 0,
                            Success = false,
                            EventName = eventDetails.Name,
                            TicketCategoryName = transactionDetail.TicketTypeId == (short)TicketType.SeasonPackage ? "Season - " + ticketCategory.Name : ticketCategory.Name,
                            IsTransactionLimitExceed = false,
                            IsTicketCategorySoldOut = true
                        });
                    }
                    /* Save Transaction Schedule Detail */
                    var currentTicket = checkoutCommand.EventTicketAttributeList.Where(s => s.Id == currentTransactionDetail.EventTicketAttributeId).FirstOrDefault();
                    if (currentTicket.ScheduleDetailId != null && currentTicket.ScheduleDetailId != 0)
                    {
                        _saveTransactionScheduleDetailProvider.SaveTransactionScheduleDetail(currentTransactionDetail.Id, (long)currentTicket.ScheduleDetailId);
                    }
                }

                try
                {
                    if (checkoutCommand.ChannelId == Channels.Feel || checkoutCommand.ChannelId == Channels.Website) // If Live Online Transaction with 0.00 price
                    {
                        var @event = _eventRepository.Get(allED.FirstOrDefault().EventId);
                        if (@event != null)
                        {
                            if (@event.MasterEventTypeId == Contracts.Enums.MasterEventType.Online && transaction.NetTicketAmount == 0)
                            {
                                _zoomMeetingProvider.CreateMeeting(transaction, true);
                                isPaymentBypass = true;
                            }
                            else if (@event.MasterEventTypeId == Contracts.Enums.MasterEventType.Online)
                            {
                                StripeAccount = _eventStripeConnectAccountProvider.GetEventStripeAccount(allED.FirstOrDefault().EventId, checkoutCommand.ChannelId);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    _logger.Log(Logging.Enums.LogCategory.Error, e);
                }
                try
                {
                    /*Check if referred transactionId already upgraded to BSP or successfull transaction, if yes then don't allow another transaction using same referral/ transaction id*/
                    if (checkoutCommand.IsBSPUpgrade && checkoutCommand.ReferralId != null)
                    {
                        var transactions = _transactionRepository.GetAllSuccessfulTransactionByReferralId(checkoutCommand.ReferralId);
                        if (transactions.Any())
                        {
                            return(new CheckoutCommandResult
                            {
                                Id = 0,
                                Success = false,
                                IsBSPUpgraded = true
                            });
                        }
                    }
                }
                catch (Exception e)
                {
                    _logger.Log(Logging.Enums.LogCategory.Error, e);
                }

                return(new CheckoutCommandResult
                {
                    Id = transactionResult.Id,
                    CartBookingModel = lstEventDetailId,
                    Transaction = transactionResult,
                    IsPaymentByPass = isPaymentBypass,
                    Success = true,
                    StripeAccount = StripeAccount,
                });
            }
            catch (Exception e)
            {
                _logger.Log(Logging.Enums.LogCategory.Error, e);
                return(new CheckoutCommandResult
                {
                });
            }
        }
Beispiel #8
0
        protected override async Task <ICommandResult> Handle(CreateBookingCommand command)
        {
            CreateBookingCommandResult results = new CreateBookingCommandResult();
            var        transaction             = _transactionRepository.Get(command.TransactionId);
            var        transactionDetail       = _transactionDetailRepository.GetByTransactionId(command.TransactionId);
            RootObject rootObject = new RootObject();

            if (transaction != null)
            {
                IDictionary <string, long> ticketCategoryValues = new Dictionary <string, long>();
                var feelBarcodemapping = _feelBarcodeMappingRepository.GetByTransactionDetailIds(transactionDetail.Select(s => s.Id)).ToList();
                if (feelBarcodemapping.Count() == 0)
                {
                    var transactionDetailModel = AutoMapper.Mapper.Map <IEnumerable <TransactionDetail> >(transactionDetail);
                    GetBarcodeResponseViewModel           getBarcodeResponseViewModel = new GetBarcodeResponseViewModel();
                    FIL.Contracts.Models.FeelBarcode.Data data = new FIL.Contracts.Models.FeelBarcode.Data();
                    Address     address     = new Address();
                    Contact     contact     = new Contact();
                    BookingType bookingType = new BookingType();
                    List <FIL.Contracts.Models.FeelBarcode.BookingDetail> bookingDetails = new List <FIL.Contracts.Models.FeelBarcode.BookingDetail>();
                    foreach (var transactiondetail in transactionDetailModel)
                    {
                        var eventTicketAttributes        = _eventTicketAttributeRepository.Get(transactiondetail.EventTicketAttributeId);
                        var eventTicketDetails           = _eventTicketDetailRepository.Get(eventTicketAttributes.EventTicketDetailId);
                        var eventDetails                 = _eventDetailRepository.Get(eventTicketDetails.EventDetailId);
                        var currentTransaction           = _transactionRepository.Get(transaction.Id);
                        var currentTransactionDetail     = _transactionDetailRepository.Get(transactiondetail.Id);
                        var currentEventTicketAttributes = _eventTicketAttributeRepository.Get((int)currentTransactionDetail.EventTicketAttributeId);
                        var currentEventTicketDetail     = _eventTicketDetailRepository.Get(currentEventTicketAttributes.EventTicketDetailId);
                        var currentTicketCategory        = _ticketCategoryRepository.Get((int)currentEventTicketDetail.TicketCategoryId);
                        var currentEventDetails          = _eventDetailRepository.Get(currentEventTicketDetail.EventDetailId);
                        var curretVenue         = _venueRepository.Get(currentEventDetails.VenueId);
                        var currentCity         = _cityRepository.Get(curretVenue.CityId);
                        var currentstate        = _stateRepository.Get(currentCity.StateId);
                        var currentcountry      = _countryRepository.Get(currentstate.CountryId);
                        var currentEvent        = _eventRepository.Get(currentEventDetails.EventId);
                        var currentCurrencyType = _currencyTypeRepository.Get(currentEventTicketAttributes.CurrencyId);

                        if (currentEvent.EventSourceId == EventSource.CitySightSeeing)
                        {
                            ticketCategoryValues.Add(currentTicketCategory.Name.ToLower(), transactiondetail.Id);
                            var      fromDate   = Convert.ToDateTime(transactiondetail.VisitDate).ToUniversalTime();
                            DateTime localTime1 = fromDate;
                            DateTime endDate    = DateTime.Now;
                            localTime1 = DateTime.SpecifyKind(localTime1, DateTimeKind.Local);
                            DateTimeOffset localTime2 = localTime1;
                            var            mystring   = localTime2.ToString();
                            var            offset     = mystring.Substring(mystring.Length - 6);
                            var            citySightSeeingEventDetailMapping             = _citySightSeeingEventDetailMappingRepository.GetByEventDetailId(currentEventDetails.Id);
                            var            citySightSeeingtickets                        = _citySightSeeingTicketRepository.Get(citySightSeeingEventDetailMapping.CitySightSeeingTicketId);
                            FIL.Contracts.Models.FeelBarcode.BookingDetail bookingDetail = new FIL.Contracts.Models.FeelBarcode.BookingDetail();
                            var citySightSeeingTicketDetails     = _citySightSeeingTicketDetailRepository.GetByTicketId(citySightSeeingtickets.TicketId);
                            var bookingDistributorReference      = RandomDigits(10);
                            var citySightSeeingTransactionDetail = new CitySightSeeingTransactionDetail();
                            if (citySightSeeingTicketDetails.TicketClass != 1)
                            {
                                citySightSeeingTransactionDetail = _citySightSeeingTransactionDetailRepository.GetByTransactionId(transactiondetail.TransactionId);
                                bookingType.from_date_time       = citySightSeeingTransactionDetail.FromDateTime;
                                bookingType.to_date_time         = citySightSeeingTransactionDetail.EndDateTime;
                                data.reservation_reference       = citySightSeeingTransactionDetail.ReservationReference;
                            }

                            var citySightSeeingLocations = _citySightSeeingLocationRepository.Get(citySightSeeingtickets.CitySightSeeingLocationId);

                            var locationDetail = await _googleMapApi.GetLatLongFromAddress(citySightSeeingLocations.Name);

                            string tz = ""; DateTime fromDateTime = DateTime.Now;; var offsetTime = "";
                            var    duration = citySightSeeingTicketDetails.Duration;
                            double lat      = Convert.ToDouble(locationDetail.Result.lat);
                            double lng      = Convert.ToDouble(locationDetail.Result.lng);
                            tz = TimeZoneLookup.GetTimeZone(lat, lng).Result;
                            TimeZoneInfo tzi           = TZConvert.GetTimeZoneInfo(tz);
                            var          visitDateTime = Convert.ToDateTime(transactiondetail.VisitDate);
                            var          timeSlot      = citySightSeeingTicketDetails.TicketClass == 1 ? "00:00" : citySightSeeingTransactionDetail.TimeSlot;
                            var          utcOffset     = tzi.BaseUtcOffset.ToString().Split(":")[0];
                            if (utcOffset.Contains("-"))
                            {
                                offset = utcOffset;
                            }
                            else
                            {
                                offset = "+" + utcOffset;
                            }
                            var formattedDateTime = visitDateTime.Year + "-" + visitDateTime.Month + "-" + visitDateTime.Day + "T" + timeSlot;
                            fromDate = Convert.ToDateTime(formattedDateTime);
                            if (duration.Contains("day"))
                            {
                                string[] day = duration.Split("day");
                                endDate = fromDate.AddDays(Convert.ToDouble(day[0]));
                            }
                            if (duration.Contains("hour"))
                            {
                                string[] hour = duration.Split("hour");
                                endDate = fromDate.AddHours(Convert.ToDouble(hour[0]));
                            }
                            var formattedEndDate = endDate.Year + "-" + endDate.Month + "-" + endDate.Day + "T" + endDate.TimeOfDay.ToString();
                            bookingType.from_date_time  = formattedDateTime + offset;
                            bookingType.to_date_time    = formattedEndDate + offset;
                            bookingDetail.ticket_type   = (currentTicketCategory.Name).ToUpper();
                            bookingDetail.count         = currentTransactionDetail.TotalTickets;
                            bookingDetail.extra_options = null;
                            bookingDetails.Add(bookingDetail);

                            bookingType.ticket_id = citySightSeeingTicketDetails.TicketId;
                            address.street        = curretVenue.Name;
                            address.postal_code   = "432243";
                            address.city          = currentCity.Name;

                            contact.address             = address;
                            contact.phonenumber         = currentTransaction.PhoneNumber;
                            data.currency               = currentCurrencyType.Code;
                            bookingType.booking_details = bookingDetails;
                            data.distributor_id         = _settings.GetConfigSetting <string>(SettingKeys.Integration.CitySightSeeing.DistributorId);
                            data.booking_type           = bookingType;
                            data.booking_name           = transaction.FirstName;
                            data.booking_email          = transaction.EmailId;
                            data.contact               = contact;
                            data.notes                 = null;
                            data.product_language      = "en";
                            data.distributor_reference = bookingDistributorReference;
                            rootObject.request_type    = "booking";
                            rootObject.data            = data;
                            var responeBooking = await GetBarcodeAsync(rootObject, transaction.Id, ticketCategoryValues);

                            if (responeBooking.data != null)
                            {
                                if (citySightSeeingTicketDetails.TicketClass != 1)
                                {
                                    citySightSeeingTransactionDetail.BookingReference            = responeBooking.data.booking_reference;
                                    citySightSeeingTransactionDetail.BookingDistributorReference = responeBooking.data.distributor_reference;
                                    citySightSeeingTransactionDetail.IsOrderConfirmed            = true;
                                    _citySightSeeingTransactionDetailRepository.Save(citySightSeeingTransactionDetail);
                                }
                                else
                                {
                                    _citySightSeeingTransactionDetailRepository.Save(new CitySightSeeingTransactionDetail
                                    {
                                        AltId                       = Guid.NewGuid(),
                                        FromDateTime                = fromDate.ToString() + offset,
                                        EndDateTime                 = endDate.ToString() + offset,
                                        HasTimeSlot                 = false,
                                        BookingReference            = responeBooking.data.booking_reference,
                                        BookingDistributorReference = bookingDistributorReference,
                                        TicketId                    = citySightSeeingtickets.TicketId,
                                        TransactionId               = command.TransactionId,
                                        IsOrderConfirmed            = true,
                                        ModifiedBy                  = command.ModifiedBy
                                    });
                                }
                                results.Success = true;
                                return(results);
                            }
                            else
                            {
                                results.Success = false;
                                return(results);
                            }
                        }
                    }
                }
                else
                {
                    results.IsExists = true;
                    return(results);
                }
            }
            else
            {
                results.Success = false;
                return(results);
            }
            return(results);
        }
        public ActionResult Get(int id)
        {
            var apiResult = TryExecute(() => _ticketCategoryRepository.Get(id), "Ticket Category fetched sucessfully");

            return(Json(apiResult, JsonRequestBehavior.AllowGet));
        }