public static void AddClient(Repository repo) { var client = new ClientEntity { PointOfContactName = UIRetriever.GetString(Nameof<ClientEntity>.Property(e => e.PointOfContactName)), PointOfContactEmail = UIRetriever.GetString(Nameof<ClientEntity>.Property(e => e.PointOfContactEmail)), CompanyInformationEntity = new CompanyInformationEntity { Name = UIRetriever.GetString(Nameof<CompanyInformationEntity>.Property(e => e.Name)), Slogan = UIRetriever.GetString(Nameof<CompanyInformationEntity>.Property(e => e.Slogan), true), AddressLine1 = UIRetriever.GetString(Nameof<CompanyInformationEntity>.Property(e => e.AddressLine1)), AddressLine2 = UIRetriever.GetString(Nameof<CompanyInformationEntity>.Property(e => e.AddressLine2), true), Locality = UIRetriever.GetString(Nameof<CompanyInformationEntity>.Property(e => e.Locality)), PostalTown = UIRetriever.GetString(Nameof<CompanyInformationEntity>.Property(e => e.PostalTown)), PostCode = UIRetriever.GetString(Nameof<CompanyInformationEntity>.Property(e => e.PostCode)), Country = UIRetriever.GetString(Nameof<CompanyInformationEntity>.Property(e => e.Country), true), WebsiteUrl = UIRetriever.GetString(Nameof<CompanyInformationEntity>.Property(e => e.WebsiteUrl), true), CellPhone = UIRetriever.GetString(Nameof<CompanyInformationEntity>.Property(e => e.CellPhone), true), OfficePhone = UIRetriever.GetString(Nameof<CompanyInformationEntity>.Property(e => e.OfficePhone), true) } }; repo.ClientsWrapper.Data.Add(client); repo.ClientsWrapper.Save(); Console.WriteLine("\nNew client \"{0}\" added.\n", client.PointOfContactName); }
/// <summary> /// Returns the file name of the newly creasted invoice /// </summary> /// <param name="invoiceEntity"></param> /// <param name="wid"></param> /// <param name="client"></param> /// <param name="companyInformationEntity"></param> /// <param name="now"></param> /// <returns></returns> public string CreateWeeklyInvoice(InvoiceEntity invoiceEntity, WeeklyInvoiceDetails wid, ClientEntity client, CompanyInformationEntity companyInformationEntity, DateTime now,string invoiceFolder) { DirectoryCreator.EnsureExistance(invoiceFolder); var pdfDoc = new Document(PageSize.A4, 50, 50, 25, 25); var pdfFileName = FileNameProvider.GetAvailableFileName(invoiceFolder + "\\Invoice-", InvoiceNameGenerator.GetName(wid.Number, now), ".pdf"); var output = new FileStream(pdfFileName, FileMode.OpenOrCreate); PdfWriter.GetInstance(pdfDoc, output); pdfDoc.Open(); HeaderFactory.Create(pdfDoc, wid.Number, invoiceEntity, companyInformationEntity, now); ClientInfoFactory.Create(pdfDoc, CompositeAddressCreator.CreateAddress(client.CompanyInformationEntity), wid.CommentsOrSpecialInstructions); CostSummaryFactory.CreateWeekly(pdfDoc, wid, invoiceEntity,now); FooterFactory.Create(pdfDoc, invoiceEntity); pdfDoc.Close(); return pdfFileName; }
public static void SendEmailWithAttachement(ClientEntity clientEntity, EmailEntity emailEntity, IInvoiceDetails invoiceDetails, string pdfFileName, DateTime now) { var subject = "Invoice #" + InvoiceNameGenerator.GetName(invoiceDetails.Number, now); var sender = new Sender(new DefaultSmtpWrapper().Data); var body = EmailBodyCreator.Create(emailEntity, clientEntity.PointOfContactName); sender.Send(clientEntity.PointOfContactEmail, subject, body, new List<string> { pdfFileName }); }
public static void ShowSentToClient(ClientEntity clientTo) { Console.WriteLine("Sent to: {0} ({1})\n\n", clientTo.PointOfContactEmail, clientTo.PointOfContactName); }