public static List <OfertaPracy> WczytywanieOfertZPliku(string sciezka) { StreamReader sr = new StreamReader(sciezka); List <string> pomocnicza = new List <string>(); while (!sr.EndOfStream) { pomocnicza.Add(sr.ReadLine()); } //teraz mamy zapisane linijki do pomocniczej //sposob w jaki oferty sa zapisane do pliku: opis;wyksztalcenie;wynagrodzenie;tytul;adresmailowy List <OfertaPracy> doZwrotu = new List <OfertaPracy>(); foreach (var item in pomocnicza) { string[] podzielone = item.Split(';'); OfertaPracy ofpr = new OfertaPracy(); ofpr.OpisOferty = podzielone[0]; ofpr.Wynagordzenie = Convert.ToInt32(podzielone[2]); ofpr.AdresMailowy = podzielone[4]; Tytul tytTMP; Enum.TryParse(podzielone[3], out tytTMP); ofpr.WymaganyTytul = tytTMP; Wyksztalcenie wykTMP; Enum.TryParse(podzielone[1], out wykTMP); ofpr.PotrzebneWyksztalcenie = wykTMP; ofpr.ID = Convert.ToInt32(podzielone[5]); doZwrotu.Add(ofpr); } sr.Close(); return(doZwrotu); }
public static List <OfertaPracy> DodajNowaOferte(OfertaPracy item, string sciezka) { StreamWriter sw = new StreamWriter(sciezka, true); string linijka = item.OpisOferty + ";"; linijka += item.PotrzebneWyksztalcenie + ";"; linijka += item.Wynagordzenie + ";"; linijka += item.WymaganyTytul + ";"; linijka += item.AdresMailowy + ";"; linijka += item.ID; sw.WriteLine(linijka); sw.Close(); return(WczytywanieOfertZPliku(sciezka)); }
public static List <OfertaPracy> UsunOferte(OfertaPracy doUsuniecia, string sciezka) { List <OfertaPracy> staraLista = WczytywanieOfertZPliku(sciezka); foreach (var item in staraLista) { if (item.ID == doUsuniecia.ID) { staraLista.Remove(item); ZapiszListeStanowisk(staraLista, sciezka); return(staraLista); } } ZapiszListeStanowisk(staraLista, sciezka); return(staraLista); }
public static void WygenerujMailaZOfertąpracy(OfertaPracy oferta, string adresmailowy) { string tresc = oferta.OpisOferty + "\nWymagane wykształcenie: " + oferta.PotrzebneWyksztalcenie + "\nwymagane tytuły naukowe: " + oferta.WymaganyTytul; MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); mail.From = new MailAddress(adresmailowy); mail.To.Add(adresmailowy); mail.Subject = "PUP - oferta pracy"; mail.Body = tresc; SmtpServer.Port = 587; SmtpServer.Credentials = new System.Net.NetworkCredential("totalnieautomatycznymailator", "Malgorzata11111995@"); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); }
public static List <OfertaPracy> EdytujOferte(OfertaPracy przed, OfertaPracy po, string sciezka) { UsunOferte(przed, sciezka); return(DodajNowaOferte(po, sciezka)); }