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>(); }
public bool UpdateUserInfo(UserDto user) { if (user != null) { //User account = Mapper.Map<UserDto, User>(user); Repository.Update<User>(user.ExposedAs<User>(Repository)); UnitOfWork.Save(); return true; } else { return false; } }