public EventTicketAttribute SaveEventTicketAttribute( CreateTicketCommand command, FIL.Contracts.Models.CreateEventV1.TicketModel ticketModel, List <FIL.Contracts.DataModels.EventTicketAttribute> eventTicketAttributes) { EventTicketAttribute eventTicketAttribute = new EventTicketAttribute(); var currentETA = eventTicketAttributes.Where(s => s.EventTicketDetailId == ticketModel.ETDId).FirstOrDefault(); eventTicketAttribute.Id = currentETA != null ? currentETA.Id : 0; eventTicketAttribute.EventTicketDetailId = ticketModel.ETDId; eventTicketAttribute.TicketCategoryNotes = ticketModel.TicketCategoryNotes != null ? ticketModel.TicketCategoryNotes : ""; eventTicketAttribute.SalesStartDateTime = DateTime.UtcNow; eventTicketAttribute.SalesEndDatetime = DateTime.UtcNow; eventTicketAttribute.TicketTypeId = TicketType.Regular; eventTicketAttribute.ChannelId = Channels.Feel; eventTicketAttribute.CurrencyId = ticketModel.CurrencyId; eventTicketAttribute.AvailableTicketForSale = ticketModel.Quantity; eventTicketAttribute.RemainingTicketForSale = ticketModel.Quantity; eventTicketAttribute.TicketCategoryDescription = ticketModel.Description == null ? "" : ticketModel.Description; eventTicketAttribute.ViewFromStand = ""; eventTicketAttribute.IsSeatSelection = false; eventTicketAttribute.Price = (decimal)ticketModel.Price; eventTicketAttribute.IsInternationalCardAllowed = true; eventTicketAttribute.IsEMIApplicable = false; eventTicketAttribute.IsEnabled = true; eventTicketAttribute.TicketValidityType = TicketValidityTypes.Fixed; eventTicketAttribute.CreatedUtc = (currentETA != null && currentETA.CreatedUtc != null) ? currentETA.CreatedUtc : DateTime.UtcNow; eventTicketAttribute.UpdatedUtc = DateTime.UtcNow; eventTicketAttribute.CreatedBy = (currentETA != null && currentETA.CreatedUtc != null) ? currentETA.CreatedBy : command.ModifiedBy; eventTicketAttribute.UpdatedBy = command.ModifiedBy; eventTicketAttribute.ModifiedBy = command.ModifiedBy; return(_eventTicketAttributeRepository.Save(eventTicketAttribute)); }
public FIL.Contracts.DataModels.EventTicketDetail SaveEventTicketDetails( CreateTicketCommand command, FIL.Contracts.Models.CreateEventV1.TicketModel ticketModel, FIL.Contracts.DataModels.EventDetail eventDetail, List <FIL.Contracts.DataModels.EventTicketDetail> eventTicketDetails) { EventTicketDetail eventTicketDetail = new EventTicketDetail(); eventTicketDetail = ticketModel.ETDId != 0 ? eventTicketDetails.Where(s => s.Id == ticketModel.ETDId).FirstOrDefault() : eventTicketDetail; eventTicketDetail.Id = ticketModel.ETDId == 0 ? 0 : ticketModel.ETDId; eventTicketDetail.AltId = ticketModel.ETDId == 0 ? Guid.NewGuid() : eventTicketDetails.Where(s => s.Id == ticketModel.ETDId).FirstOrDefault().AltId; eventTicketDetail.EventDetailId = eventDetail.Id; eventTicketDetail.TicketCategoryId = ticketModel.TicketCategoryId; eventTicketDetail.IsEnabled = ticketModel.isEnabled; eventTicketDetail.CreatedUtc = eventTicketDetail.Id != 0 ? eventTicketDetail.CreatedUtc : DateTime.UtcNow; eventTicketDetail.UpdatedUtc = eventTicketDetail.Id != 0 ? DateTime.UtcNow : eventTicketDetail.CreatedUtc; eventTicketDetail.CreatedBy = eventTicketDetail.Id != 0 ? eventTicketDetail.CreatedBy : command.ModifiedBy; eventTicketDetail.UpdatedBy = command.ModifiedBy; eventTicketDetail.ModifiedBy = command.ModifiedBy; return(_eventTicketDetailRepository.Save(eventTicketDetail)); }
public void SaveEventticketDetailTicketCategoryTypeMappings(CreateTicketCommand command, FIL.Contracts.Models.CreateEventV1.TicketModel ticketModel) { try { EventTicketDetailTicketCategoryTypeMapping eventTicketDetailTicketCategoryTypeMapping = new EventTicketDetailTicketCategoryTypeMapping(); eventTicketDetailTicketCategoryTypeMapping.EventTicketDetailId = ticketModel.ETDId; eventTicketDetailTicketCategoryTypeMapping.TicketCategoryTypeId = ticketModel.TicketCategoryTypeId; eventTicketDetailTicketCategoryTypeMapping.TicketCategorySubTypeId = 1; eventTicketDetailTicketCategoryTypeMapping.UpdatedUtc = DateTime.UtcNow; eventTicketDetailTicketCategoryTypeMapping.IsEnabled = true; _eventTicketDetailTicketCategoryTypeMappingRepository.Save(eventTicketDetailTicketCategoryTypeMapping); } catch (Exception e) { } }
public FIL.Contracts.DataModels.TicketCategory SaveTicketCategory(CreateTicketCommand command, FIL.Contracts.Models.CreateEventV1.TicketModel ticketModel) { var ticketCat = _ticketCategoryRepository.GetByNameAndId(ticketModel.Name, ticketModel.TicketCategoryId); if (ticketCat == null) // if category exists with same name { FIL.Contracts.DataModels.TicketCategory ticketCategoryObject = new FIL.Contracts.DataModels.TicketCategory(); ticketCategoryObject.Name = ticketModel.Name; ticketCategoryObject.IsEnabled = true; ticketCategoryObject.CreatedUtc = DateTime.UtcNow; ticketCategoryObject.CreatedBy = command.ModifiedBy; ticketCategoryObject.ModifiedBy = command.ModifiedBy; var ticketCategory = _ticketCategoryRepository.Save(ticketCategoryObject); return(ticketCategory); } else { return(ticketCat); } }
public TicketQueryResult Handle(TicketQuery query) { try { List <FIL.Contracts.Models.CreateEventV1.TicketModel> ticketModelList = new List <FIL.Contracts.Models.CreateEventV1.TicketModel>(); var currentEvent = _eventRepository.Get(query.EventId); if (currentEvent == null) { return(new TicketQueryResult { Success = true }); } var eventDetail = _eventDetailRepository.GetByEventId(query.EventId); if (eventDetail == null) { return(new TicketQueryResult { Success = true, IsDraft = true, IsValidLink = true, Tickets = ticketModelList }); } var eventTicketDetails = _eventTicketDetailRepository.GetByEventDetailId(eventDetail.Id); var eventTicketDetailTicketCategoryMappingData = _eventTicketDetailTicketCategoryTypeMappingRepository.GetByEventTicketDetails(eventTicketDetails.Select(s => s.Id).ToList()).ToList(); if (query.TicketCategoryTypeId == 2) { eventTicketDetailTicketCategoryMappingData = eventTicketDetailTicketCategoryMappingData.Where(s => s.TicketCategoryTypeId == 2).ToList(); eventTicketDetails = eventTicketDetails.Where(p => eventTicketDetailTicketCategoryMappingData.Any(p2 => p2.EventTicketDetailId == p.Id) || (p.TicketCategoryId == 19452 || p.TicketCategoryId == 12259)); if (!eventTicketDetails.Any()) { return(new TicketQueryResult { EventDetailId = eventDetail.Id, EventId = currentEvent.Id, Success = true, IsValidLink = true, Tickets = ticketModelList }); } } else { eventTicketDetailTicketCategoryMappingData = eventTicketDetailTicketCategoryMappingData.Where(s => s.TicketCategoryTypeId != 2).ToList(); eventTicketDetails = eventTicketDetails.Where(p => eventTicketDetailTicketCategoryMappingData.Any(p2 => p2.EventTicketDetailId == p.Id)); } var ticketCategories = _ticketCategoryRepository.GetByTicketCategoryIds(eventTicketDetails.Select(s => s.TicketCategoryId)); var eventTicketAttributes = _eventTicketAttributeRepository.GetByEventTicketDetailIds(eventTicketDetails.Select(s => s.Id)); var currency = _currencyTypeRepository.GetByCurrencyIds(eventTicketAttributes.Select(s => s.CurrencyId).ToList()); var eventTicketDiscountDetails = _eventTicketDiscountDetailRepository.GetAllByEventTicketAttributeIds(eventTicketAttributes.Select(s => s.Id).ToList()); var discounts = _discountRepository.GetAllDiscountsByIds(eventTicketDiscountDetails.Select(s => (long)s.DiscountId).ToList()); var discountPromoCodes = _discountPromoCodeRepository.GetAllDiscountIds(discounts.Select(s => (long)s.Id).ToList()); foreach (var currentEventTicketDetail in eventTicketDetails) { FIL.Contracts.Models.CreateEventV1.TicketModel newTicketModel = new FIL.Contracts.Models.CreateEventV1.TicketModel(); var currentTicketCat = ticketCategories.Where(s => s.Id == currentEventTicketDetail.TicketCategoryId).FirstOrDefault(); var currentEventTicketAttribute = eventTicketAttributes.Where(s => s.EventTicketDetailId == currentEventTicketDetail.Id).FirstOrDefault(); var currentEventTicketDetailTicketCategoryMappingData = eventTicketDetailTicketCategoryMappingData.Where(s => s.EventTicketDetailId == currentEventTicketDetail.Id).FirstOrDefault(); var currentEventTicketDiscountDetails = eventTicketDiscountDetails.Where(s => s.EventTicketAttributeId == currentEventTicketAttribute.Id).FirstOrDefault(); var currentDiscount = currentEventTicketDiscountDetails != null?discounts.Where(s => s.Id == currentEventTicketDiscountDetails.DiscountId).FirstOrDefault() : null; var currentDiscountPromoCodes = currentDiscount != null?discountPromoCodes.Where(s => s.DiscountId == currentDiscount.Id).FirstOrDefault() : null; var donationDetail = new FIL.Contracts.DataModels.DonationDetail(); if (currentEventTicketDetail.TicketCategoryId == 19452 || currentEventTicketDetail.TicketCategoryId == 12259) { donationDetail = _donationDetailRepository.GetByEventId(query.EventId); } newTicketModel.TicketAltId = currentEventTicketDetail.AltId; newTicketModel.ETDId = currentEventTicketDetail.Id; newTicketModel.TicketCategoryId = currentTicketCat.Id; newTicketModel.Name = currentTicketCat.Name; newTicketModel.Price = currentEventTicketAttribute.Price; newTicketModel.Quantity = currentEventTicketAttribute.AvailableTicketForSale; newTicketModel.Description = currentEventTicketAttribute.TicketCategoryDescription; newTicketModel.CurrencyId = currentEventTicketAttribute.CurrencyId; newTicketModel.TicketCategoryTypeId = currentEventTicketDetailTicketCategoryMappingData == null ? 1 : (currentEventTicketDetailTicketCategoryMappingData != null && currentEventTicketDetailTicketCategoryMappingData.TicketCategoryTypeId == 1) ? 1 : 2; newTicketModel.isEnabled = currentEventTicketDetail.IsEnabled; newTicketModel.CurrencyCode = currency.Where(s => s.Id == currentEventTicketAttribute.CurrencyId).FirstOrDefault().Code; newTicketModel.TotalQuantity = currentEventTicketAttribute.AvailableTicketForSale; newTicketModel.RemainingQuantity = currentEventTicketAttribute.RemainingTicketForSale; newTicketModel.DiscountAmount = currentDiscount != null && currentDiscount.DiscountValueTypeId == Contracts.Enums.DiscountValueType.Flat ? currentDiscount.DiscountValue : 0; newTicketModel.IsDiscountEnable = currentEventTicketDiscountDetails != null ? currentEventTicketDiscountDetails.IsEnabled : false; newTicketModel.DiscountPercentage = currentDiscount != null && currentDiscount.DiscountValueTypeId == Contracts.Enums.DiscountValueType.Percentage ? currentDiscount.DiscountValue : 0; newTicketModel.PromoCode = currentDiscountPromoCodes != null ? currentDiscountPromoCodes.PromoCode : null; newTicketModel.DiscountValueType = currentDiscount != null ? currentDiscount.DiscountValueTypeId : Contracts.Enums.DiscountValueType.Flat; newTicketModel.DonationAmount1 = donationDetail != null ? donationDetail.DonationAmount1 : 0; newTicketModel.DonationAmount2 = donationDetail != null ? donationDetail.DonationAmount2 : 0; newTicketModel.DonationAmount3 = donationDetail != null ? donationDetail.DonationAmount3 : 0; ticketModelList.Add(newTicketModel); } return(new TicketQueryResult { EventDetailId = eventDetail.Id, EventId = currentEvent.Id, Success = true, IsValidLink = true, Tickets = ticketModelList }); } catch (Exception e) { return(new TicketQueryResult { }); } }