public void DisplayInvoice(InvoiceBl invoice) { _ioHelper.PrintMessage($"Invoice number: {invoice.Number} {Environment.NewLine}" + $"Invoice beginning date: {invoice.BeginningDate} {Environment.NewLine}" + $"Invoice generation date: {invoice.GenerationDate} {Environment.NewLine}" + $"Total cost of Invoice to be paid: {invoice.TotalCostToBePaid} {Environment.NewLine}"); }
static void Main(string[] args) { try { ICrmRepository DAL = new CrmDal(); IInvoiceRepository invoiceRepository = new InvoiceDal(); var bl = new CrmBl(); var invoiceBl = new InvoiceBl(); var test = new CrmDal(); var invoiceDal = new InvoiceDal(); var optimalBl = new OptimalBl(); //var agent = bl.AddServiceAgent("Omer", "111"); var newagent = new ServiceAgent("Iron", "3456"); var client = new Client("hds", "ss", 5555, 3, "yaffo", "0546", 5); var package = new Package("pp", 11, 50, new DateTime(2000, 11, 10), 120, 150, 0.3, true, false, false); test.AddPackage(package); //var lines = bl.GetClientLines(1); // invoiceBl.AddPayment(1, new DateTime(2000, 11, 20), 150); //Console.WriteLine(invoiceRepository.GetClientType(4).Id); //Console.WriteLine(invoiceBl.GetCallsPayment(4, new DateTime(2000, 11, 10))); //var p = invoiceRepository.GetPackage(3); //Console.WriteLine(p.PackageName); // var calls = invoiceRepository.GetCalls(3, new DateTime(2000,11,10)); //Console.WriteLine(invoiceBl.GetMinutesLeft(3, new DateTime(2000,11,10))); } catch (Exception e) { Console.WriteLine(e.Message); } }
public async Task SendAsync(string email, string filePath, InvoiceBl invoice) { await Task.Run(() => { MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); mail.From = new MailAddress("*****@*****.**"); mail.To.Add(email); mail.Subject = $"Telecom system Invoice for the period: {invoice.BeginningDate.ToShortDateString()} " + $"to: {invoice.GenerationDate.ToShortDateString()}"; mail.Body = $"Dear {invoice.Subscriber.Name}{Environment.NewLine}" + $"As an attachment we are sending an invoice for telecom services provided to you by our company. {Environment.NewLine}" + $"An invoice covers period mentioned in the subject.{Environment.NewLine}" + $"Whole informations about payment are included in the attached invoice.{Environment.NewLine}" + $"In addition, we encourage to settle of receivables quickly. {Environment.NewLine}" + $"Best regards,{Environment.NewLine}{Environment.NewLine}" + $"Telecom company business manager{Environment.NewLine}" + $"Jacob Joshua"; Attachment attachment; attachment = new Attachment(filePath); mail.Attachments.Add(attachment); SmtpServer.Port = 587; SmtpServer.Credentials = new NetworkCredential(ConfigurationManager.AppSettings["UserName"], ConfigurationManager.AppSettings["Password"]); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); attachment.Dispose(); //required to delete created file after sending an email }); }
public async Task <string> SaveToFileAsync(string filePath, InvoiceBl invoice) { return(await Task.Run <string>(() => { string json = JsonConvert.SerializeObject(invoice, Formatting.Indented); File.WriteAllText((filePath), json); return json; })); }
public Invoice MapInvoiceBlToInvoice(InvoiceBl invoiceBl) { var invoice = new Invoice { BeginningDate = invoiceBl.BeginningDate, GenerationDate = invoiceBl.GenerationDate, Number = invoiceBl.Number, Subscriber = MapSubscriberBlToSubscriber(invoiceBl.Subscriber), TotalCostOfConnections = invoiceBl.TotalCostOfConnections, TotalCostOfTextMessages = invoiceBl.TotalCostOfTextMessages, TotalOffersCost = invoiceBl.TotalOffersCost, TotalCostToBePaid = invoiceBl.TotalCostToBePaid, PhoneReports = MapPhoneReportBlListToPhoneReportList(invoiceBl.PhoneReports) }; return(invoice); }
public string GetFilePath(string serializerExtension, InvoiceBl invoice) { var filePath = _ioHelper.GetStringFromUser("Enter the path of the file ( to save in working directory leave it empty ): "); while (!Directory.Exists(filePath)) { if (String.IsNullOrEmpty(filePath)) { filePath = Directory.GetCurrentDirectory(); continue; } filePath = _ioHelper.GetStringFromUser($"Wrong path, insert the path again: {Environment.NewLine}"); } return(Path.Combine(filePath, $"{invoice.Number}.{serializerExtension.ToLowerInvariant()}")); }
public InvoiceBl Capture(SubscriberBl subscriber, List <PhoneReportBl> reportsBl) { var newInvoice = new InvoiceBl { BeginningDate = _invoiceService.GetDateOfPreviousInvoice(subscriber), GenerationDate = DateTime.Now, Number = _invoiceService.GenerateInvoiceNumber(subscriber), Subscriber = subscriber, TotalCostOfConnections = _reportService.GetTotalCostOfConnections(subscriber), TotalCostOfTextMessages = _reportService.GetTotalCostOfTextMessages(subscriber), TotalOffersCost = _reportService.GetTotalCostBasedOnOffers(subscriber), TotalCostToBePaid = _reportService.GetTotalCostToBePaid(subscriber), PhoneReports = reportsBl }; return(newInvoice); }
public async Task <string> SaveToFileAsync(string filePath, InvoiceBl invoice) { return(await Task.Run(() => { XmlSerializer serializer = new XmlSerializer(typeof(InvoiceBl)); using (var write = new StreamWriter(filePath)) { serializer.Serialize(write, invoice); } using (var textWriter = new StringWriter()) { serializer.Serialize(textWriter, invoice); return textWriter.ToString(); } })); }
private void idBtnSave_Click(object sender, EventArgs e) { var ObjInvoiceMaster = GetValueFromTextBoxInvoiceMaster(); var ObjInvoiceItem = GetInvoiceItems(); InvoiceBl.SaveCustomer(ObjInvoiceMaster); var ErrorCounter = 0; var ErrorMessage = "Following fields should not be empty \n\n"; if (string.IsNullOrEmpty(ObjInvoiceMaster.BilledTo)) { ErrorCounter++; ErrorMessage += ErrorCounter.ToString() + "] " + "Please selecct Billed To \n"; } if (string.IsNullOrEmpty(ObjInvoiceMaster.TransportMode)) { ErrorCounter++; ErrorMessage += ErrorCounter.ToString() + "] " + "Please select Transport Mode \n"; } if (string.IsNullOrEmpty(ObjInvoiceMaster.PoNum)) { ErrorCounter++; ErrorMessage += ErrorCounter.ToString() + "] " + "Please enter Po. No. \n"; } if (idDgvInvoice.Rows.Count == 0) { ErrorCounter++; ErrorMessage += ErrorCounter.ToString() + "] " + "Please add items\n"; } if (ErrorCounter > 0) { MessageBox.Show(ErrorMessage, "Warning !..."); return; } //if(string.IsNullOrEmpty(ObjInvoiceMaster.ID)) }
public async Task <InvoiceBl> AddAsync(InvoiceBl invoiceBl, int indexOfSubscriber) { var invoice = _dataObjectMapper.MapInvoiceBlToInvoice(invoiceBl); Invoice invoiceToReturn; using (var dbContext = _dbContextFactory()) { var chosenSubscriber = await dbContext.SubscriberDbSet .SingleOrDefaultAsync(s => s.Id == indexOfSubscriber); invoice.Subscriber = chosenSubscriber; return(await Task.Run(() => { invoiceToReturn = dbContext.InvoiceDbSet.Add(invoice); dbContext.SaveChanges(); return _dataObjectMapper.MapInvoiceToInvoiceBl(invoiceToReturn); })); } }
public InvoiceBl MapInvoiceToInvoiceBl(Invoice invoice) { var invoiceBl = new InvoiceBl { BeginningDate = invoice.BeginningDate, GenerationDate = invoice.GenerationDate, Number = invoice.Number, TotalCostOfConnections = invoice.TotalCostOfConnections, TotalCostOfTextMessages = invoice.TotalCostOfTextMessages, TotalOffersCost = invoice.TotalOffersCost, TotalCostToBePaid = invoice.TotalCostToBePaid }; if (invoice.PhoneReports != null) { invoiceBl.PhoneReports = MapPhoneReportListToPhoneReportBlList(invoice.PhoneReports); } if (invoice.Subscriber != null) { invoiceBl.Subscriber = MapSubscriberToSubscriberBl(invoice.Subscriber); } return(invoiceBl); }
public string GetFilePath(string serializerExtension, InvoiceBl invoice) { return(_invoiceDataCapture.GetFilePath(serializerExtension, invoice)); }
public async Task AddInvoiceAsync(InvoiceBl invoiceBl, int indexOfSubscriber) { await _invoiceService.AddAsync(invoiceBl, indexOfSubscriber); }
public string GetCurrentDirectory(string serializerExtension, InvoiceBl invoice) { var filePath = Directory.GetCurrentDirectory(); return(Path.Combine(filePath, $"{invoice.Number}.{serializerExtension.ToLowerInvariant()}")); }