Ejemplo n.º 1
0
 public virtual void CreateTicketEcrDimension(TicketEcrDimension dimension)
 {
     EcrProductDimensionRepository.Add(dimension);
 }
Ejemplo n.º 2
0
        private void CreateNewTicketsInDb(List <ImportedTicket> importedTickets, Product[] ecrProductList)
        {
            var count = 0;

            foreach (var iticket in importedTickets)
            {
                count++;
                var product = ecrProductList.FirstOrDefault(x => x.SysID.Equals(iticket.EcrProductSku));

                if (product == null)
                {
                    Log("ECR Product Import: CreateNewTicketsInDb() => Product not found SKU: " + iticket.EcrProductSku);
                    continue;
                }

                var existingTicket = TicketService.GetTicketByEcrSysId(iticket.EcrProductSku);

                if (existingTicket != null)
                {
                    continue;
                }

                var ticket = new Ticket
                {
                    StartDate               = iticket.StartDate,
                    AdultTicketEnabled      = true,
                    ChildTicketEnabled      = true,
                    FamilyTicketEnabled     = true,
                    ConcessionTicketEnabled = false,
                    AgentsOnly              = false,
                    EnabledForAgents        = false,
                    AttractionApi           = null,
                    AttractionDisplayOrder  = null,
                    DateCreated             = DateTime.Now,
                    Enabled          = true,
                    Description      = iticket.Description,
                    IsPackage        = false,
                    EcrVersionId     = (int)EcrVersion.Three,
                    NcEcrProductCode = iticket.EcrProductSku,
                    TicketType       = MatchTicketType(iticket.TicketType),
                    MicroSiteId      = iticket.MicroSiteId,
                    Name             = iticket.Name,
                    HasMobile        = true
                };

                if (!string.IsNullOrEmpty(iticket.FulfilmentInstructions))
                {
                    var len           = iticket.FulfilmentInstructions.Length;
                    var ticketDetails = iticket.FulfilmentInstructions;

                    ticket.TicketTextLine2 = (len <= 130) ? ticketDetails : ticketDetails.Substring(0, 130);
                    len -= 130;

                    if (len > 0)
                    {
                        ticket.TicketTextLine3 = (len <= 130)
                            ? ticketDetails.Substring(130, len)
                            : ticketDetails.Substring(130, 130);
                        len -= 130;
                    }

                    if (len > 0)
                    {
                        ticket.TicketTextBottomLine = (len <= 40)
                            ? ticketDetails.Substring(260, len)
                            : ticketDetails.Substring(260, 40);
                    }
                }

                TicketService.CreateTicket(ticket);

                if (ticket.Id.Equals(Guid.Empty))
                {
                    Log("Failed to create ticket into DB ecr ticket id sysid:" + iticket.EcrProductSku);
                }
                else //create related product dimensions - *** leave this for later as it is not needed at this stage.
                {
                    var dimensions = iticket.EcrProductDimensionList;

                    if (product != null && dimensions.Count > 0)
                    {
                        foreach (var dimension in product.ProductDimensions)
                        {
                            if (string.IsNullOrEmpty(dimension.Name))
                            {
                                continue;
                            }

                            var ecrDimension = new TicketEcrDimension
                            {
                                Name           = dimension.Name,
                                TicketId       = ticket.Id.ToString(),
                                EcrSysId       = product.SysID,
                                ProductTypeUid = dimension.ProductUID,
                                ProductTypeSku = dimension.SysID
                            };

                            TicketService.CreateTicketEcrDimension(ecrDimension);
                        }
                    }
                }
            }

            Log("ECR Product Import: " + count + "Products Imported.");
        }