当前位置: 首页>>代码示例>>C#>>正文


C# Ticket.Update方法代码示例

本文整理汇总了C#中Ticket.Update方法的典型用法代码示例。如果您正苦于以下问题:C# Ticket.Update方法的具体用法?C# Ticket.Update怎么用?C# Ticket.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ticket的用法示例。


在下文中一共展示了Ticket.Update方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RefundTicket

		//REMOVED BY DAVEB 10/01
		//private static void RefundTicket(Usr actionUsr, Ticket ticket)
		//{
		//    RefundTicket(actionUsr, ticket, false);
		//}

		private static void RefundTicket(Usr actionUsr, Ticket ticket, bool refundIncludeBookingFee, bool areFundsAlreadyReleased)
        {
            try
            {
                if (ticket.IsAllowedToRefund(actionUsr, Math.Round(ticket.Price + (refundIncludeBookingFee ? ticket.BookingFee : 0), 2)))
                {
                    InvoiceDataHolder creditDH = ticket.Invoice.CreateCredit();
                    creditDH.ActionUsrK = actionUsr.K;
                    // Remove all invoice items, except that of tickets
                    for (int i = creditDH.InvoiceItemDataHolderList.Count - 1; i >= 0; i--)
                    {
                        // Remove only the ticket invoice item (and booking fee if refundIncludeBookingFee)
                        if (creditDH.InvoiceItemDataHolderList[i].BuyableObjectK != ticket.K || creditDH.InvoiceItemDataHolderList[i].BuyableObjectType != Model.Entities.ObjectType.Ticket
                            || (creditDH.InvoiceItemDataHolderList[i].Type != InvoiceItem.Types.EventTickets
                                && (creditDH.InvoiceItemDataHolderList[i].Type != InvoiceItem.Types.EventTicketsBookingFee || !refundIncludeBookingFee)))
                        {
                            creditDH.InvoiceItemDataHolderList.RemoveAt(i);
                        }
                    }

                    if (ticket.Invoice.AmountAllowedToCredit < Math.Abs(creditDH.Total))
                        throw new Exception("Cannot credit more than " + ticket.Invoice.AmountAllowedToCredit.ToString("c") + " for Invoice #" + ticket.Invoice.K.ToString());

					decimal refundAmountRemaining = Math.Abs(creditDH.Total);
                    SecPay secPay = new SecPay();

                    // Refund that amount from transfers
                    foreach (InvoiceTransfer invoiceTransfer in ticket.Invoice.SuccessfulInvoiceTransfers)
                    {
                        try
                        {
                            if (refundAmountRemaining <= 0)
                                break;

							decimal refundAmount = Math.Round(invoiceTransfer.Amount, 2) < Math.Round(refundAmountRemaining, 2) ? Math.Round(invoiceTransfer.Amount, 2) : Math.Round(refundAmountRemaining, 2);

                            // refund refundAmount from that transfer, the subtract that from refundAmountRemaining
                            Transfer transferToRefund = new Transfer(invoiceTransfer.TransferK);

                            secPay.MakeRefund(transferToRefund, Guid.NewGuid(), Usr.Current.K, refundAmount);
                            if (secPay.Transfer.Status == Transfer.StatusEnum.Success)
                            {
                                refundAmountRemaining = Math.Round(refundAmountRemaining - refundAmount, 2);
                                transferToRefund.UpdateAndResolveOverapplied();
                                Utilities.EmailTransfer(secPay.Transfer, true, false);
                            }
                            else
                                throw new Exception("SecPay refund #");// + secPay.Transfer.K.ToString() + " failed, by user: " + Usr.Current.NickName + ", for ticket #" + ticket.K.ToString());
                        }
                        catch (Exception ex)
                        {
                            Utilities.AdminEmailAlert("Exception in Ticket.RefundTicket(Ticket ticket)", "Exception in Ticket.RefundTicket(Ticket ticket)", ex, ticket);
                        }
                    }

                    if (Math.Round(refundAmountRemaining, 2) <= 0)
                    {
                        creditDH.DueDateTime = Time.Now;
                        Invoice credit = creditDH.UpdateInsertDelete();
                        // Get latest invoice from DB
                        ticket.Invoice = null;
                        ticket.Invoice.ApplyCreditToThisInvoice(credit);

                        if (!ticket.Invoice.Paid)
                            throw new Exception("Invoice #" + ticket.Invoice.K.ToString() + " was not refunded completely, please verify manually.");

                        ticket.Cancelled = true;
						ticket.CancelledBeforeFundsRelease = !areFundsAlreadyReleased;
						ticket.CancelledDateTime = Time.Now;
                        ticket.Update();
						if (ticket.BuyerUsr != null)
						{
							ticket.BuyerUsr.SetPrefsNextTicketFeedbackDate();
						}
                        Utilities.EmailTicket(ticket);
                    }
                }
            }
            catch (Exception ex)
            {
                Utilities.AdminEmailAlert("Exception in Ticket.RefundTicket(Ticket ticket)", "Exception in Ticket.RefundTicket(Ticket ticket)", ex, ticket);
                throw ex;
            }
        }
开发者ID:davelondon,项目名称:dontstayin,代码行数:90,代码来源:Ticket.cs

示例2: ValidateAndLockInvoices

        /// <summary>
		/// Checks for duplicates, then checks for any locked invoice items, and then checks that all invoice items are ready to be processed. If all checks pass, then it locks all IBuyable invoice items.
		/// </summary>
		/// <returns>True if all checks pass and all IBuyable invoice items are locked. Otherwise false</returns>
		private bool ValidateAndLockInvoices()
		{
			// Check for duplicate invoices
            if (DoesDuplicateGuidExistInDb())
            {
                this.HandleDuplicates();
                return false;
            }
            else if (this.Invoices.Count > 0 && this.Invoices[0].K > 0)
            {
                foreach (InvoiceDataHolder idh in this.Invoices)
                {
                    if (idh.K == 0 || idh.Paid)
                        return false;
                }
                return true;
            }
            // Ensure all invoice items arent locked
            else
            {
                double lockedSeconds = 0d;

                if (this.CampaignCredits.Count > 0)
                {
                    lockedSeconds = this.CampaignCreditsLockedSeconds();
                    if (lockedSeconds <= 0)
                    {
                        for (int i = 0; i < this.CampaignCredits.Count; i++)
                        {
                            this.CampaignCredits[i] = new CampaignCredit(CampaignCredits[i].K);
                            if (this.CampaignCredits[i].Enabled)
                                return false;
                        }
                    }
                }
                else
                {
                    lockedSeconds = this.InvoiceItemsLockedSeconds();
                }
                if (lockedSeconds > 0)
                {
                    // Add a few seconds, so users dont try again too soon and find the item locked again (as they have shown to do).
                    lockedSeconds += 5;

                    ProcessingVal.ErrorMessage = string.Format(INVOICE_ITEMS_LOCKED, lockedSeconds);
                    ProcessException(new Exception(ProcessingVal.ErrorMessage), null, "", false);
                    return false;
                }
                else
                {
                    // Now lock items
                    this.LockInvoiceItems();

                    foreach (InvoiceDataHolder idh in this.Invoices)
                    {
                        // Need to add CardNumberHash to EventTickets for validation processing
                        if (CardNumberHash != new Guid())
                        {
                            foreach (InvoiceItemDataHolder iidh in idh.InvoiceItemDataHolderList)
                            {
                                if (iidh.BuyableObjectType == Model.Entities.ObjectType.Ticket && iidh.Type == InvoiceItem.Types.EventTickets)
                                {
                                    try
                                    {
                                        Ticket buyingTicket = new Ticket(iidh.BuyableObjectK);
                                        buyingTicket.CardNumberHash = CardNumberHash;
                                        buyingTicket.Update();
                                    }
                                    catch
                                    { }
                                }
                            }
                        }
                        try
                        {
                            // Checks that all items are ready to be processed. If any are not, then it will throw an exception
                            if (!idh.IsReadyToProcess())
                            {
								throw new DsiUserFriendlyException(ITEMS_NOT_READY_FOR_PROCESSING);
                                
                            }
							foreach (CampaignCredit cc in this.CampaignCredits)
							{
								if (cc.BuyableObject != null && cc.BuyableObject is IBuyableCredits && !((IBuyableCredits)cc.BuyableObject).IsReadyForProcessingCredits(cc.InvoiceItemType, Math.Abs(cc.Credits)))
								{
									throw new DsiUserFriendlyException(ITEMS_ALREADY_PROCESSED);
								}								
							}
                        }
                        catch (DsiUserFriendlyException ex)
                        {
                            ProcessingVal.ErrorMessage = ex.Message;
                            ProcessException(ex);
                            return false;
                        }
                        catch (Exception ex)
//.........这里部分代码省略.........
开发者ID:davelondon,项目名称:dontstayin,代码行数:101,代码来源:Payment.ascx.cs

示例3: UpdateTicketsFromPaymentControl

		public List<Ticket> UpdateTicketsFromPaymentControl()
		{
			List<Ticket> ticketsPurchased = new List<Ticket>();
			foreach (InvoiceDataHolder idh in this.Payment.Invoices)
			{
				if (idh.K > 0)
				{
					Invoice invoice = new Invoice(idh.K);
					//string ticketPurchaseMessage = "You just purchased ";
					//int ticketCounter = 0;
					foreach (InvoiceItem invoiceItem in invoice.Items)
					{
						if (invoiceItem.BuyableObjectType.Equals(Model.Entities.ObjectType.Ticket) && invoiceItem.Type.Equals(InvoiceItem.Types.EventTickets))
						{
							Ticket ticket = new Ticket(invoiceItem.BuyableObjectK);

							// Only update once. If page is refreshed, it shouldnt redo the updating of this ticket.
							if (ticket.InvoiceItemK == 0)
							{
								Transfer transfer = new Transfer();

								if (this.Payment.SecPay != null && this.Payment.SecPay.Transfer != null && this.Payment.SecPay.Transfer.K > 0)
									transfer = this.Payment.SecPay.Transfer;
								else if (invoice.SuccessfulAppliedTransfers.Count > 0 && invoice.SuccessfulAppliedTransfers[0].K > 0)
									transfer = invoice.SuccessfulAppliedTransfers[0];

								if (transfer.K > 0)
								{
									bool ticketWasEnabled = ticket.Enabled;
									ticket.AddressArea = Payment.CurrentUsr.AddressArea;
									if (ticket.AddressCountryK == 0)
										ticket.AddressCountryK = Payment.CurrentUsr.AddressCountryK;
									ticket.AddressPostcode = transfer.CardPostcode;
									ticket.AddressStreet = transfer.CardAddress1;
									ticket.AddressTown = Payment.CurrentUsr.AddressTown;
									ticket.CardNumberDigits = transfer.CardDigits;
									ticket.CardNumberEnd = transfer.CardNumberEnd;
									ticket.CardNumberHash = transfer.CardNumberHash;
									ticket.CardCV2 = transfer.CardCV2;
									string cardName = Utilities.StripTitleFromName(transfer.CardName);
									ticket.FirstName = Cambro.Misc.Utility.Snip(Utilities.GetFirstName(cardName), 100);
									ticket.LastName = Cambro.Misc.Utility.Snip(Utilities.GetLastName(cardName), 100);
									if (!ticket.Enabled && invoiceItem.K > 0 && transfer.Status == Transfer.StatusEnum.Success && Math.Round(transfer.Amount, 2) >= Math.Round(ticket.Price + ticket.BookingFee, 2) && ticket.Invoice != null && ticket.Invoice.Paid)
									{
										ticket.Enabled = true;
									}
									ticket.InvoiceItemK = invoiceItem.K;
									ticket.Mobile = Payment.CurrentUsr.Mobile;
									ticket.MobileCountryCode = Payment.CurrentUsr.MobileCountryCode;
									ticket.Update();

									if (ticket.Enabled)
									{
										Utilities.EmailStyledTicket(this.StyledObject, ticket);
										ticketsPurchased.Add(ticket);
									}

									if (!ticketWasEnabled && ticket.Enabled)
									{
										ticket.TicketRun.CalculateSoldTicketsAndUpdate();
									}
								}
								else
								{
									Utilities.AdminEmailAlert("<p>Error in Styled.Pay.UpdateTicketsFromPaymentControl(). Transfer not found.</p>",
																"Error in Styled.Pay.UpdateTicketsFromPaymentControl(). Transfer not found.", new DsiUserFriendlyException("Error in UpdateTicketsFromPaymentControl()"),
																new List<IBobAsHTML>() { ticket, invoice }, new string[] { Vars.EMAIL_ADDRESS_TIMI });
								}
							}
						}
					}
				}
			}

			return ticketsPurchased;
		}
开发者ID:davelondon,项目名称:dontstayin,代码行数:76,代码来源:Pay.ascx.cs


注:本文中的Ticket.Update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。