Example #1
0
        public async Task SaveCompany(CompanyCredentials company)
        {
            company.DateEmailSend = DateTime.Now;
            await _context.CompanyCredentials.AddAsync(company);

            await _context.SaveChangesAsync();
        }
Example #2
0
 public AddCompanyViewModel()
 {
     _companies             = new ObservableCollection <CompanyCredentials>();
     company                = new CompanyCredentials();
     company.CompanyAddress = new CompanyAddress();
     _container             = new UnityContainer();
     _fileWriter            = _container.Resolve <FileWriter>();
     _emailService          = _container.Resolve <EmailService>();
     _companyRepo           = _container.Resolve <CompanyRepo>();
 }
Example #3
0
        private void WriteTextEmail(CompanyCredentials company, string path, bool isSendAtt)
        {
            var          typeEmail = isSendAtt ? "EmailToSend.docx" : "EmailToSendWithoutAtt.docx";
            WordDocument docToRead = new WordDocument(String.Format("{0}/{1}", rootWritePath, typeEmail));

            docToRead.ReplaceHrDataInEmail(company.NameHR);

            docToRead.ReplaceDataInDocument("{company}", company.Name);
            docToRead.ReplaceDataInDocument("{country}", company.CompanyAddress.Country);
            docToRead.Save(String.Format("{0}/EmailToSend.txt", path), FormatType.Txt);
            docToRead.Close();
        }
Example #4
0
 public ActionResult <ObjectResult> UpdateCredentials([FromBody] CompanyCredentials credentials)
 {
     try
     {
         CompanyService companyService = new CompanyService(Startup.BeePlaceDataBaseConnectionString);
         var            partner        = new CompanyPartner();
         partner.Email    = credentials.Email;
         partner.Password = credentials.Password;
         companyService.UpdateCompanyPartnerCredentials(partner);
         return(StatusCode((int)HttpStatusCode.OK, credentials));
     }
     catch (Exception e)
     {
         return(StatusCode((int)HttpStatusCode.InternalServerError, e.Message));
     }
 }
Example #5
0
        private MailMessage CreateMail(CompanyCredentials company, bool isAtt)
        {
            var companyPath = String.Format("{0}/{1}", rootPath, company.Name);

            MailMessage mail = new MailMessage();

            mail.From = new MailAddress(userName);
            mail.To.Add(company.Email);
            mail.Subject = SubjectEmail(company.SubjectEmail);
            mail.Body    = _fileReader.GetEmailText(companyPath);

            var zipPath = String.Format("{0}/VladimirVrucinicDoc.zip", companyPath);

            mail.Attachments.Add(new Attachment(zipPath));
            return(mail);
        }
Example #6
0
 public bool WriteDocuments(CompanyCredentials company, bool isSendAtt)
 {
     pathCompany = String.Format("{0}/{1}", rootWritePath, company.Name);
     CreateCompanyFolder(pathCompany);
     try
     {
         WriteTextEmail(company, pathCompany, isSendAtt);
         WriteCoverLetter(company, pathCompany);
         CopyFile(pathCompany);
         ZipFiles(pathCompany);
         return(true);
     }
     catch (IOException e)
     {
         System.Windows.MessageBox.Show(String.Format("File is open, please close! Company name: {0}", company.Name), "Confiramtion", MessageBoxButton.OK, MessageBoxImage.Warning);
         return(false);
     }
 }
Example #7
0
 public void AddCompany(object x)
 {
     company.SelectedTypeEmail = SelectedTypeEmail;
     _companies.Add(company);
     company = new CompanyCredentials();
     company.CompanyAddress         = new CompanyAddress();
     SelectedTypeEmail              = null;
     company.CompanyAddress.City    = _companies.LastOrDefault().CompanyAddress.City;
     company.CompanyAddress.Country = _companies.LastOrDefault().CompanyAddress.Country;
     OnPropertyChanged("SelectedTypeEmail");
     OnPropertyChanged("SubjectEmail");
     OnPropertyChanged("CompanyName");
     OnPropertyChanged("CompanyCity");
     OnPropertyChanged("CompanyEmail");
     OnPropertyChanged("CompanyAddress");
     OnPropertyChanged("CompanyCountry");
     OnPropertyChanged("CompanyNameHR");
     OnPropertyChanged("Companies");
 }
Example #8
0
        private void WriteCoverLetter(CompanyCredentials company, string path)
        {
            WordDocument docToRead = new WordDocument(String.Format("{0}/CoverLetterVladimirVrucinic.docx", rootWritePath));

            docToRead.ReplaceDataInDocument("{company}", company.Name);
            docToRead.Replace("{date}", DateTime.Now.ToString("MMMM dd, yyyy"), true, false);
            docToRead.ReplaceHrData(company.NameHR);

            docToRead.ReplaceDataInDocument("{city}", company.CompanyAddress.City);
            docToRead.ReplaceAddress(company.CompanyAddress.Address);

            DocToPDFConverter converter   = new DocToPDFConverter();
            PdfDocument       pdfDocument = converter.ConvertToPDF(docToRead);

            pdfDocument.Save(String.Format("{0}/CoverLetterVladimirVrucinic.pdf", path));

            pdfDocument.Close(true);
            docToRead.Close();
        }
Example #9
0
        public async Task SendEmail(CompanyCredentials company, bool isAtt)
        {
            try
            {
                using (SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"))
                {
                    SmtpServer.Port        = 587;
                    SmtpServer.Credentials = new System.Net.NetworkCredential(userName, pass);
                    SmtpServer.EnableSsl   = true;

                    await SmtpServer.SendMailAsync(CreateMail(company, isAtt));
                }
            }
            catch (System.Exception e)
            {
                //_logger.Error("Exeption message: " + e.Message);
                //_logger.Error("Inner exeption message: " + e.InnerException.Message);
                //TODO: mess error comp name
                throw;
            }
        }
Example #10
0
 public async Task UpdateSendingDate(CompanyCredentials company)
 {
     company.DateEmailSend = DateTime.Now;
     _context.Update(company);
     await _context.SaveChangesAsync();
 }