internal bool restituieCartea(int impId, string rewiew) { bool ok = false; using (var context = new ModelGeneral()) { foreach (var imp in context.IMPRUMUTs) { if (impId == imp.ImprumutId && imp.DataScadenta.HasValue == false) { imp.DataScadenta = DateTime.Now; REVIEW rev = new REVIEW() { Text = rewiew }; imp.REVIEW.Add(rev); ok = true; } } /*if (countCititorBehavior(cititor) >= 2) * changeStateCititor(cititor); */ context.SaveChanges(); } return(ok); }
internal bool agaugaCarte(CARTE carte) { // aceasta metoda introduce cartea carte de nr_carti_ori in baza de date using (var context = new ModelGeneral()) { if (existAutor(carte.AUTOR)) { carte.AUTOR = getAutor(carte.AUTOR); } if (existGen(carte.GEN)) { carte.GEN = getGen(carte.GEN); } //Console.WriteLine(carte.AUTOR.AutorId); CARTE c = new CARTE() { AutorId = carte.AUTOR.AutorId, GenId = carte.GEN.GenId, Titlu = carte.Titlu }; context.CARTEs.Add(c); context.SaveChanges(); } return(true); }
internal void changeStateCititor(CITITOR cititor) { using (var context = new ModelGeneral()) { context.CITITORs.Add(cititor); context.Entry(cititor).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } }
//aceasta metoda adauga un gen in bd daca este cazul internal void adaugaGen(GEN g) { if (!existGen(g)) { using (var context = new ModelGeneral()) { GEN gen = new GEN() { Descriere = g.Descriere.Trim() }; context.GENs.Add(gen); context.SaveChanges(); } } }
//aceasta metoda adauga autorul primit ca argument in baza de date internal void adaugaAutor(AUTOR a) { if (!existAutor(a)) { using (var context = new ModelGeneral()) { AUTOR autor = new AUTOR() { Nume = a.Nume.Trim(), Prenume = a.Prenume.Trim() }; context.AUTORs.Add(autor); context.SaveChanges(); } } }
//acesta metoda adauga un cititor in baza de date internal void adaugaCititor(CITITOR cit) { if (!existCititor(cit)) { using (var context = new ModelGeneral()) { CITITOR c = new CITITOR() { Adresa = cit.Adresa.Trim(), Email = cit.Email.Trim(), Nume = cit.Nume.Trim(), Prenume = cit.Prenume.Trim() }; context.CITITORs.Add(c); context.SaveChanges(); } } }
//aceasta metoda returneaza tru daca s-a putut face imprumutul si il realizeaza , false c.c. internal bool imprumutaCarte(int carteID, CITITOR cit) { if (verfDisponibilitateCarte(carteID)) { CARTE c = new CARTE(); using (var context = new ModelGeneral()) { foreach (var carte in context.CARTEs) { if (carte.CarteId == carteID) { c = carte; break; } } cit.CititorId = getCitirorId(cit); IMPRUMUT imp = new IMPRUMUT() { CARTE = c, DataImprumut = DateTime.Now, DataRestituire = DateTime.Now.AddDays(14), CITITOR = cit }; Console.WriteLine(cit.Email); context.IMPRUMUTs.Add(imp); context.SaveChanges(); } return(true); } else { return(false); } }