本文整理汇总了C#中Invoice.ExposedAs方法的典型用法代码示例。如果您正苦于以下问题:C# Invoice.ExposedAs方法的具体用法?C# Invoice.ExposedAs怎么用?C# Invoice.ExposedAs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Invoice
的用法示例。
在下文中一共展示了Invoice.ExposedAs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateSubscriptionInvoice
/// <summary>
/// Create a subscription invoice
/// </summary>
/// <param name="planId"></param>
/// <param name="userId"></param>
/// <returns></returns>
public Invoice CreateSubscriptionInvoice(Braintree.Plan planDetail, Guid userId, string transactionId)
{
//var planDetail = new PaymentService(UnitOfWork, Repository, Settings).GetPlanById(planId);
try
{
User user = Repository.FindById<User>(userId);
if (planDetail == null || user == null)
{
throw new ArgumentException("Generate subscription invoice. Cannot find Plan or User with id:" + userId);
}
var invoice = new Invoice()
{
InvoiceNumber = GetInvoiceNumber(),
User = user,
Description = string.Format(InvoiceConst.InvoiceSubscriptionDescription, planDetail.BillingFrequency.Value),
CreatedDate = DateTime.UtcNow,
GST = SubtractGSTCalculator(planDetail.Price.Value),
Amount = planDetail.Price.Value,
Currency = planDetail.CurrencyIsoCode,
Duration = planDetail.BillingFrequency.Value,
Type = InvoiceType.Subscription,
PaymentStatus = true,
TransactionId = transactionId,
};
Repository.Insert<Invoice>(invoice);
UnitOfWork.Save();
if (!invoice.Id.Equals(Guid.Empty))
{
string mailContent = GetEmailContentOfInvoice(invoice.ExposedAs<InvoiceDto>());
string mailToPdf = TranformToInvoiceTemplate(invoice.User.ExposedAs<UserDto>(),
invoice.ExposedAs<InvoiceDto>(), "months", ConstEmailTemplateKey.SubscriptionInvoiceTemplate, null);
System.Threading.Tasks.Task.Factory.StartNew(() =>
{
byte[] pdfAsByte = HtmlToPdf.GetPdfData(mailToPdf, baseUrl);
string fileName = string.Format("invoice_{0}.pdf", invoice.InvoiceNumber);
SendInvoice(fileName, pdfAsByte, mailContent, user.Email, ConstEmailSubject.SubscriptionInvoice);
});
}
else
{
throw new ArgumentException("Cannot save subscription invoice to database");
}
return invoice;
}
catch (Exception e)
{
throw new ArgumentException(e.Message);
}
}
示例2: CreateTranscriptionInvoice
public InvoiceDto CreateTranscriptionInvoice(decimal amount, int duration, decimal ratePerMinute, BookingDto booking, UserDto user, string transactionId)
{
Invoice invoice = new Invoice
{
InvoiceNumber = GetInvoiceNumber(),
Amount = amount,
GST = SubtractGSTCalculator(amount),
RatePerMinute = ratePerMinute,
Duration = duration,
Type = InvoiceType.OrderTranscript,
CreatedDate = DateTime.UtcNow,
ModifiedDate = DateTime.UtcNow,
SentDate = DateTime.UtcNow,
User = user.ExposedAs<User>(Repository),
Currency = Currency.AUD.ToString(),
PaymentStatus = true,
Booking = booking.ExposedAs<Booking>(Repository)
};
invoice.Description = string.Format(InvoiceConst.InvoiceCallRecordDescription, invoice.Booking.ReferenceNo);
Repository.Insert<Invoice>(invoice);
UnitOfWork.Save();
if (!invoice.Id.Equals(Guid.Empty))
{
var mailContent = GetEmailContentOfInvoice(invoice.ExposedAs<InvoiceDto>());
var mailPdfContent = TranformToInvoiceTemplate(user, invoice.ExposedAs<InvoiceDto>(),
null, ConstEmailTemplateKey.ConsultationInvoiceTemplate, null);
System.Threading.Tasks.Task.Factory.StartNew(() =>
{
byte[] pdfAsByte = HtmlToPdf.GetPdfData(mailPdfContent, baseUrl);
string fileName = GenerateInvoiceName(invoice.InvoiceNumber);
SendInvoice(fileName, pdfAsByte, mailContent, user.Email, ConstEmailSubject.TranscriptionInvoice);
});
}
else
{
throw new ArgumentException("Cannot save transcription invoice to database");
}
return invoice.ExposedAs<InvoiceDto>();
}
示例3: CreateConsultationInvoice
/// <summary>
/// Create a consultation invoice
/// </summary>
/// <param name="minimumCharge">true if apply minimum charge</param>
/// <returns></returns>
public InvoiceDto CreateConsultationInvoice(decimal amount, Guid bookingId, bool minimumCharge, bool isCustomer, string transactionId)
{
var SystemConfig = new SystemConfigService(UnitOfWork, Repository, Settings);
string emailAddress = string.Empty;
Invoice invoice = new Invoice(amount, InvoiceType.Consultation,
Currency.AUD.ToString(), string.Empty,
true, null, DateTime.UtcNow, DateTime.UtcNow);
invoice.InvoiceNumber = GetInvoiceNumber();
Booking booking = Repository.FindById<Booking>(bookingId);
invoice.User = isCustomer ? booking.Customer : booking.Specialist;
emailAddress = invoice.User.Email;
invoice.Description = string.Format(InvoiceConst.InvoiceNormalDescription, booking.ReferenceNo, invoice.User.ExposedAs<UserDto>().Name);
Log.Debug("CreateConsultationInvoice - before calculate GST - Customer:" + booking.Customer.UserName
+ " - specialist:" + booking.Specialist.UserName
+ " - Amount: " + amount
+ " - GSTRegistered:" + booking.Specialist.Profile.GstRegistered
+ " - SpecializationGST:" + booking.Specialization.GST);
invoice.GST = booking.Specialist.Profile.GstRegistered
? booking.Specialization.GST
? SubtractGSTCalculator(amount)
: 0
: 0;
Log.Debug("CreateConsultationInvoice - after calculate GST - Customer:" + booking.Customer.UserName
+ " - specialist:" + booking.Specialist.UserName
+ " - Amount: " + amount + " - Invoice Calculated GST:" + invoice.GST + " - function calculate GST return:" + SubtractGSTCalculator(amount));
invoice.TransactionId = transactionId;
if (minimumCharge) // minimum charge invoice
{
invoice.Description = string.Format(InvoiceConst.InvoiceCancelDescription, booking.ReferenceNo) + InvoiceConst.InvoiceApplyMinimumDescription;
invoice.Duration = 0;
invoice.RatePerMinute = booking.RatePerMinute;
invoice.ConsultationType = ConsultationType.MinimumCharge;
invoice.Booking = booking;
invoice.DeclineBookingRate = isCustomer ? booking.CustomerMinCharge : booking.SpecialistMinCharge;
invoice.Amount = invoice.DeclineBookingRate;
}
else // normal consultation invoice
{
var call = Repository.Query<Call>().FirstOrDefault(x => x.Booking.Id.Equals(bookingId));
if (call == null)
{
throw new ArgumentException("Generate consulation invoice with booking Id: " + bookingId);
}
ConsultationType consultType;
if (call.Booking.Type == BookingType.ASAP)
{
consultType = ConsultationType.StandardHour;
}
else
{
Enum.TryParse(call.Booking.Type.ToString(), out consultType);
}
invoice.Booking = call.Booking;
invoice.Duration = call.Duration;
invoice.RatePerMinute = isCustomer ? call.Booking.CostPerMinute : call.Booking.RatePerMinute;
invoice.ConsultationType = consultType;
if (call.Duration < Convert.ToInt32(SystemConfig.GetByKey(ParamatricBusinessRules.STARTING_TIME.ToString()).Value))
{
invoice.Description += InvoiceConst.InvoiceApplyMinimumDescription;
}
}
Repository.Insert<Invoice>(invoice);
UnitOfWork.Save();
Log.Debug("CreateConsultationInvoice - after insert invoice - Customer:" + booking.Customer.UserName
+ " - specialist:" + booking.Specialist.UserName
+ " - Amount: " + invoice.Amount
+ " - Invoice Calculated GST:" + invoice.GST);
if (invoice.Id.Equals(Guid.Empty))
{
throw new ArgumentException("Cannot save consultation invoice to database");
}
return invoice.ExposedAs<InvoiceDto>();
}