public async Task <IActionResult> Edit(int id, [Bind("id,imie,nazwisko,data_urodzenia,plec,miasto,liczba_dzieci")] Studenci studenci) { if (id != studenci.id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(studenci); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StudenciExists(studenci.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(studenci)); }
public static void Uruchom() { Studenci.listaStudentów = Studenci.Deserializuj(Studenci.sciezkaBazyDanych); int i; do { i = Menu(); switch (i) { case 1: Fabryka.Wybor(); break; case 2: WyświetlanieIModyfikacja.Wybor(); break; case 0: Studenci.Serializuj(Studenci.sciezkaBazyDanych, Studenci.listaStudentów); break; default: break; } } while (i != 0); }
// // GET: /Admin/Students/Delete/5 public ActionResult Delete(int id) { _logger.Info("StudenciController.Delete => HTTP GET"); ViewBag.Current = "Students"; Studenci student = _repo1.GetStudentByID(id); return(View(student)); }
// // GET: /Admin/Students/Edit/5 public ActionResult Edit(int id) { _logger.Info("StudenciController.Edit => HTTP GET"); ViewBag.Current = "Students"; Studenci student = _repo1.GetStudentByID(id); ViewBag.ListaGrup = _repo.GetAllGroups; return(View(student)); }
public ActionResult DeleteConfirmed(int id) { _logger.Info("StudenciController.Delete => SUCCES = Delete Studenci| HTTP POST"); Studenci student = (Studenci)_repo1.GetStudentByID(id); _repo1.DeleteStudent(student); _repo1.Save(); TempData["message"] = "Usunięto Studenta!"; TempData["status"] = "valid"; return(RedirectToAction("List")); }
public async Task <IActionResult> Create([Bind("id,imie,nazwisko,data_urodzenia,plec,miasto,liczba_dzieci")] Studenci studenci) { if (ModelState.IsValid) { _context.Add(studenci); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(studenci)); }
public async Task <IActionResult> Index(string nazwa) { List <Studenci> stud = new List <Studenci>(); if (nazwa != null) { query = nazwa; } var conn = _context.Database.GetDbConnection(); try { conn.Open(); using (var command = conn.CreateCommand()) { command.CommandText = query; DbDataReader reader = await command.ExecuteReaderAsync(); if (reader.HasRows) { while (await reader.ReadAsync()) { var row = new Studenci { id = reader.GetInt32(6), imie = reader.GetString(0), nazwisko = reader.GetString(1), data_urodzenia = reader.GetDateTime(2), miasto = reader.GetString(4), liczba_dzieci = reader.GetInt32(5) }; stud.Add(row); } } reader.Dispose(); } } finally { conn.Close(); } ViewData["nazwa"] = nazwa; return(View(stud)); // return View(await _context.Studenci.ToListAsync()); //return View(await _context.Studenci.ToListAsync()); }
public ActionResult Edit(Studenci student) { _logger.Info("StudenciController.Edit => Entering| HTTP POST"); if (ModelState.IsValid) { _repo1.EditStudent(student); _repo1.Save(); _logger.Info("StudenciController.Edit => SUCCES = Edit Studenci| HTTP POST"); TempData["message"] = "Zauktalizowano studenta!"; TempData["status"] = "valid"; return(RedirectToAction("List")); } _logger.Info("StudenciController.Edit => FAILED = Edit Studenci| HTTP POST"); ViewBag.ListaGrup = _repo.GetAllGroups; TempData["message"] = "Nie udało się uaktualnić studenta! Taki student istnieje!"; TempData["status"] = "invalid"; ViewBag.Current = "Students"; return(View(student)); }
public override bool IsUserInRole(string username, string rolename) { Prowadzacy user = repository.GetProwadzacyByName(username); Studenci student = null; if (user == null) { student = repository.GetStudentByName(username); } if (!repository.ProwadzacyExists(user)) { return(false); } if (student != null && !repository.StudentExists(student)) { return(false); } return(user.admin); }
public static void Wybor() { int i; do { i = Menu(); switch (i) { case 1: Studenci.DodajStudentaDziennego(); break; case 2: Studenci.DodajStudentaZaocznego(); break; default: break; } } while (i != 0); }
public ActionResult Add(Studenci student) { _logger.Info("StudenciController.Add => Entering | HTTP POST"); if (!_repo1.StudentExists(student) && !_repo1.IndeksExists(student)) { if (ModelState.IsValid) { student.haslo = FormsAuthentication.HashPasswordForStoringInConfigFile(student.haslo.Trim(), "md5"); _repo1.AddStudent(student); _repo1.Save(); _logger.Info("StudenciController.Add => SUCCES = Add Studenci| HTTP POST"); TempData["message"] = "Pomyślnie dodano nowego studenta!"; TempData["status"] = "valid"; return(RedirectToAction("List")); } } _logger.Info("StudenciController.Add => FAILED = Add Studenci | HTTP POST"); TempData["message"] = "Nie udało się dodać studenta! Taki student istnieje!"; TempData["status"] = "invalid"; ViewBag.Current = "Students"; ViewBag.ListaGrup = _repo.GetAllGroups; return(View(student)); }
private void InsertStudentsToGroups(string filepath, string filename, string groupname) { string fullpath = Server.MapPath("/excelfolder/") + filename; string constr = string.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=""Excel 12.0 Xml;HDR=YES;""", fullpath); var Econ = new OleDbConnection(constr); string query = string.Format("Select * from [{0}]", "Studenci$"); OleDbCommand Ecom = new OleDbCommand(query, Econ); Econ.Open(); DataSet ds = new DataSet(); OleDbDataAdapter oda = new OleDbDataAdapter(query, Econ); Econ.Close(); oda.Fill(ds); if (db.Grupy.Where(s => s.nazwa == groupname).Count() == 0) { Grupy gr = new Grupy(); gr.nazwa = groupname; db.Grupy.Add(gr); db.SaveChanges(); } int group_id = db.Grupy.Where(s => s.nazwa == groupname).ToList().ElementAt(0).id; DataTable dt = ds.Tables[0]; foreach (DataRow x in dt.Rows) { if (x.ItemArray.Length == 3) { Studenci st = new Studenci(); st.indeks = Int32.Parse(x.ItemArray.ElementAt(0).ToString()); st.imie = x.ItemArray.ElementAt(1).ToString(); st.nazwisko = x.ItemArray.ElementAt(2).ToString(); if (db.Studenci.Where(s => s.indeks == st.indeks).Count() == 0) { db.Studenci.Add(st); db.SaveChanges(); } if (db.StudenciGrupy.Where(s => (s.id_studenta == st.indeks) && (s.id_grupy == group_id)).Count() == 0) { StudenciGrupy sg = new StudenciGrupy(); sg.id_grupy = group_id; sg.id_studenta = st.indeks; db.StudenciGrupy.Add(sg); db.SaveChanges(); } } if (x.ItemArray.Length == 4) { Studenci st = new Studenci(); st.indeks = Int32.Parse(x.ItemArray.ElementAt(0).ToString()); st.imie = x.ItemArray.ElementAt(1).ToString(); st.nazwisko = x.ItemArray.ElementAt(2).ToString(); st.mail = x.ItemArray.ElementAt(3).ToString(); if (db.Studenci.Where(s => s.indeks == st.indeks).Count() == 0) { db.Studenci.Add(st); db.SaveChanges(); } if (db.StudenciGrupy.Where(s => (s.id_studenta == st.indeks) && (s.id_grupy == group_id)).Count() == 0) { StudenciGrupy sg = new StudenciGrupy(); sg.id_grupy = group_id; sg.id_studenta = st.indeks; db.StudenciGrupy.Add(sg); db.SaveChanges(); } } } }
public List <WidokStudenta> PobierzWybranychStudentow(sbyte idGrupy) { return(Studenci.Where(a => a.Grupa.Id_grupa == idGrupy).ToList()); }
public void DeleteStudent(Studenci student) { entities.Studenci.Remove(student); }
public void EditStudent(Studenci student) { entities.Entry(student).State = EntityState.Modified; }
public void AddStudent(Studenci student) { entities.Studenci.Add(student); }
public bool IndeksExists(Studenci student) { return(entities.Studenci.Any(m => m.nr_indeksu == student.nr_indeksu)); }
public bool StudentExists(Studenci student) { return(entities.Studenci.Any(m => m.login == student.login)); }
public List <WidokStudenta> PobierzWybranychStudentowRok(int rok) { return(Studenci.Where(a => a.Grupa.Rok == rok).ToList()); }
public static void Wybor() { Delegat d = new Delegat(Studenci.Wyświetl); d += Studenci.PytanieOZapisywanie; int i; do { i = Menu(); switch (i) { case 1: Studenci.Wyświetl(Studenci.listaStudentów); Console.ReadKey(); break; case 2: List <Student> lista = Studenci.WyszukajStudentówDziennych(); d(lista); break; case 3: List <Student> lista2 = Studenci.WyszukajStudentówZaocznych(); d(lista2); break; case 4: int ind = Studenci.ZnajdźStudenta(); if (ind >= 0) { Studenci.listaStudentów[ind].WyświetlPełneInformacje(); } Console.ReadKey(); break; case 5: int numer = Studenci.ZnajdźStudenta(); if (numer >= 0) { Modyfikacja.Wybor(numer); } break; case 6: Studenci.listaStudentów.Sort(); d(Studenci.listaStudentów); break; case 7: Studenci.listaStudentów.Sort(new Student.PoWydziale()); d(Studenci.listaStudentów); break; case 8: Studenci.listaStudentów.Sort(new Student.PoKierunku()); d(Studenci.listaStudentów); break; case 9: Studenci.listaStudentów.Sort(new Student.PoŚredniej()); d(Studenci.listaStudentów); break; case 10: Studenci.Wyświetl(Studenci.Wczytywanie()); Console.ReadKey(); break; default: break; } } while (i != 0); }