public IActionResult CreateTranzactie(Tranzactie tranzactie) { var tranzactieRepository = new TranzactieRepository(); tranzactieRepository.InsertTranzactie(tranzactie); return(RedirectToAction("ListareTranzactii")); }
// Functie care insereasa o noua tranzactie in baza de date public void InsertTranzactie(Tranzactie tranzactie) { DateTime data = DateTime.UtcNow.Date; var query = $"INSERT INTO Tranzactii(AngajatID, ClientID, MasinaID, Data, Suma) " + $"VALUES({tranzactie.AngajatID}, {tranzactie.ClientID}, {tranzactie.MasinaID}, " + $"'{data}', {tranzactie.Suma})"; this.ExecuteQuery(query); }
public Tranzactie creazaTranzactie(TipTranzactie tip, string iban, string data, double suma) { var IBAN = new PlainText(iban); var Data = new PlainText(data); var tranzactie = new Tranzactie(tip, IBAN, Data, suma); return(tranzactie); }
// Functie care returneaza o tranzactie din baza de date dupa ID public Tranzactie GetTranzactie(int id) { var query = $"SELECT * FROM Tranzactii WHERE TranzactieID={id};"; var dataTable = this.ExecuteQuery(query); Tranzactie tranzactie = dataTable.AsEnumerable().Select(row => new Tranzactie { TranzactieID = row.Field <int>("TranzactieID"), AngajatID = row.Field <int>("AngajatID"), ClientID = row.Field <int>("ClientID"), MasinaID = row.Field <int>("MasinaID"), Data = row.Field <string>("Data"), Suma = row.Field <double>("Suma") }).FirstOrDefault(); tranzactie.masina = this.ExecuteQuery($"SELECT * FROM Masini m, Modele md, Producatori pd " + $"WHERE m.ModelID = md.ModelID AND md.ProducatorID = pd.ProducatorID AND m.MasinaID={tranzactie.MasinaID}").AsEnumerable().Select(row => new Masina { MasinaID = row.Field <int>("MasinaID"), Model = row.Field <string>("NumeModel"), Producator = row.Field <string>("NumeProducator"), ModelID = row.Field <int>("ModelID"), Pret = row.Field <int>("Pret"), Motorizare = row.Field <string>("Motorizare"), Combustibil = row.Field <string>("Combustibil"), Culoare = row.Field <string>("Culoare"), AnFabricatie = row.Field <string>("AnFabricatie"), KM = row.Field <int>("KM"), Descriere = row.Field <string>("Descriere") }).FirstOrDefault(); tranzactie.angajat = this.ExecuteQuery($"SELECT * FROM Angajati WHERE AngajatID={tranzactie.AngajatID};").AsEnumerable().Select(row => new Angajat { AngajatID = row.Field <int>("AngajatID"), Nume = row.Field <string>("Nume"), Prenume = row.Field <string>("Prenume"), Email = row.Field <string>("Email"), Adresa = row.Field <string>("Adresa"), Telefon = row.Field <string>("Telefon") }).FirstOrDefault(); tranzactie.client = this.ExecuteQuery($"SELECT * FROM Clienti WHERE ClientID={tranzactie.ClientID};").AsEnumerable().Select(row => new Client { ClientID = row.Field <int>("ClientID"), Nume = row.Field <string>("Nume"), Prenume = row.Field <string>("Prenume"), Email = row.Field <string>("Email"), Adresa = row.Field <string>("Adresa"), Telefon = row.Field <string>("Telefon") }).FirstOrDefault(); return(tranzactie); }
public TransactionItemReportModel(Tranzactie tranzactie) { TranzactieId = tranzactie.TranzactieId; DataTranzactie = tranzactie.DataTranzactie; CodTranzactie = tranzactie.CodTranzactie; SumaTranzactie = tranzactie.SumaTranzactie; TipTranzactie = tranzactie.TipTranzactie; ReferintaClient = tranzactie.ReferintaClient; DetaliiTranzactie = tranzactie.DetaliiTranzactie; InformatiiPentruClient = tranzactie.InformatiiPentruClient; DataValutei = tranzactie.DataValutei; }
private static void TransferInterbancar(Date db) { string message = string.Empty; Console.WriteLine("Care este numele dvs?"); string numeUtilizator = Console.ReadLine(); Console.WriteLine("Care este parola dvs?"); string parola = Console.ReadLine(); ContBancar contInitializator = null; foreach (var cont in db.ConturiBancare) { if (numeUtilizator == cont.Nume && parola == cont.Parola) { contInitializator = cont; break; } } if (contInitializator == null) { message = $"Contul cautat nu a fost gasit."; Console.WriteLine(message); log.Warn(message); return; } Console.WriteLine("Introduceti contul Iban"); string iban = Console.ReadLine(); Console.WriteLine("Introduceti suma pe care vreti sa o transferati."); string sumaDeTransferatstring = Console.ReadLine(); bool sumaTransferata = int.TryParse(sumaDeTransferatstring, out int sumaDeTransferat); if (sumaTransferata == true) { Tranzactie tranzactie = contInitializator.TransferaInterbancar(sumaDeTransferat, iban); if (tranzactie != null) { db.Tranzactii.Add(tranzactie); db.SaveData(); message = "Tranzactia fost trimisa catre procesare."; Console.WriteLine(message); log.Info(message); } else { message = "Tranzactie esuata"; Console.WriteLine(message); log.Warn(message); } } }