public IActionResult UpdateStudentNote([FromRoute] int studentIndex, [FromRoute] int lectureIndex, [FromRoute] int noteIndex, [FromBody] Ocena note) { Student student = _educationSystemData.GetStudents() .FirstOrDefault(studentObj => studentObj.Indeks == studentIndex); Przedmiot lecture = _educationSystemData.GetLectures() .FirstOrDefault(lectureObj => lectureObj.IdPrzedmiotu == lectureIndex); if (student == null || lecture == null || note == null) { return(NotFound()); } Ocena noteTemp = _educationSystemData.GetNotes() .FirstOrDefault(noteObj => noteObj.IdOceny == noteIndex && noteObj.IdPrzedmiot == lecture.Id && noteObj.IdStudent == student.Id); if (noteTemp == null) { return(NotFound()); } if (note.Wartosc != 2.0 && note.Wartosc != 2.5 && note.Wartosc != 3.0 && note.Wartosc != 3.5 && note.Wartosc != 4.0 && note.Wartosc != 4.5 && note.Wartosc != 5.0) { return(BadRequest()); } _educationSystemData.UpdateStudentNote(student, lecture, noteTemp, note); return(Ok()); }
public ActionResult TworzenieOceny(FormCollection collection) { if (Session["Status"] != "Admin" && Session["Status"] != "Nauczyciel") { return(RedirectToAction("Index", "Home")); } double ocenka = Convert.ToDouble(collection["ocena"]); int wage = Convert.ToInt32(collection["waga"]); string trusc = collection["tresc"]; ViewBag.NauczycielID = Session["UserID"]; Ocena ocena1 = new Ocena { ocena = ocenka, waga = wage, data = DateTime.Now, tresc = trusc, PrzedmiotID = (int)TempData.Peek("idprzedmiotu"), NauczycielID = Int32.Parse(ViewBag.NauczycielID), UczenID = (int)TempData.Peek("iducznia") }; db.Oceny.Add(ocena1); db.SaveChanges(); return(View(ocena1)); }
public IActionResult DeleteNotesFromLecture([FromRoute] int lectureIndex, [FromRoute] int idNote) { Przedmiot lecture = _educationSystemData.GetLectures() .FirstOrDefault(lectureObj => lectureObj.IdPrzedmiotu == lectureIndex); Ocena note = _educationSystemData.GetNotes() .FirstOrDefault(noteObj => noteObj.IdOceny == idNote && noteObj.IdPrzedmiot == lecture.Id); if (lecture == null || note == null) { return(NotFound()); } Student student = _educationSystemData.GetStudents() .FirstOrDefault(studentObj => studentObj.Oceny.Any(ocenyObj => ocenyObj == note.Id)); if (student == null) { return(NotFound()); } _educationSystemData.DeleteNote(student, lecture, note); return(Ok()); }
private void lbOcene_SelectedIndexChanged(object sender, EventArgs e) { try { ISession s = DataLayer.getSession(); Object ob = lbOcene.SelectedItem; int pos = ob.ToString().IndexOf(" "); int idOcene = int.Parse(ob.ToString().Substring(0, pos)); Ocena ocena = s.Get <Ocena>(idOcene); if (ocena.GetType() == typeof(BrojcanaOcena)) { rbBrojcana.Checked = true; txtBrojcana.Text = ocena.Broj.ToString(); txtOpisna.Text = ""; } else if (ocena.GetType() == typeof(OpisnaOcena)) { rbOpisna.Checked = true; txtOpisna.Text = ocena.Opis; txtBrojcana.Text = ""; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public ActionResult TestSummary() { Ocena ocena = (Ocena)Session["testGrade"]; ViewBag.testPoints = Session["testPoints"]; return(View(db.Oceny.Where(o => o.id_oceny == ocena.id_oceny).FirstOrDefault())); }
// FrmOcena internal void SacuvajOcenu(TextBox txtOcena, ComboBox cmbKategorija, Korisnik k, Film f) { if (!ProveraUnosaOcene(txtOcena, cmbKategorija)) { MessageBox.Show("Došlo je do greške, pokušajte ponovo"); return; } ; Ocena o = new Ocena(); o.Film = f; o.Korisnik = k; o.Kategorija = cmbKategorija.SelectedItem as Kategorija; o.OcenaFilma = Convert.ToInt32(txtOcena.Text); if (o.OcenaFilma < 1 || o.OcenaFilma > 10) { MessageBox.Show("Ocena mora biti u intervalu 1-10"); return; } Ocena sacuvanaOcena = Komunikacija.Instance.SacuvajOcenu(o); if (sacuvanaOcena != null) { MessageBox.Show("Ocena je uspešno sačuvana"); SrediFrmOcena(txtOcena); } else { MessageBox.Show("Ocena nije sačuvana"); SrediFrmOcena(txtOcena); } }
public IActionResult UpdateStudentNote([FromRoute] int studentIndex, [FromRoute] int lectureIndex, [FromRoute] int noteIndex) { Student student = _educationSystemData.GetStudents() .FirstOrDefault(studentObj => studentObj.Indeks == studentIndex); Przedmiot lecture = _educationSystemData.GetLectures() .FirstOrDefault(lectureObj => lectureObj.IdPrzedmiotu == lectureIndex); if (student == null || lecture == null) { return(NotFound()); } Ocena note = _educationSystemData.GetNotes() .FirstOrDefault(noteObj => noteObj.IdOceny == noteIndex && noteObj.IdPrzedmiot == lecture.Id && noteObj.IdStudent == student.Id); if (note == null) { return(NotFound()); } _educationSystemData.DeleteStudentNote(student, lecture, note); return(Ok()); }
private void BtnCitajImaOcenu_Click(object sender, EventArgs e) { try { ISession s = DataLayer.getSession(); Ucenik ucenik = s.Load <Ucenik>(1); foreach (Ocena o in ucenik.ListaOcenaUcenikIma) { MessageBox.Show(o.Broj.ToString()); } Ocena ocena = s.Load <Ocena>(1); foreach (Ucenik u in ocena.ListaUcenikaOcena) { MessageBox.Show(u.Ime); } foreach (Predmet p in ocena.ListaPredmetaOcena) { MessageBox.Show(p.Naziv); } Predmet predmet = s.Load <Predmet>(1); foreach (Ucenik u in predmet.ListaUcenikaPredmet) { MessageBox.Show(u.Ime); } foreach (Ocena o in predmet.ListaOcenaPredmet) { MessageBox.Show(o.Broj.ToString()); } s.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnBrisiOcenu_Click(object sender, EventArgs e) { try { ISession s = DataLayer.getSession(); Object ob = lbOcene.SelectedItem; if (ob == null) { MessageBox.Show("Selektujte ocenu koju zelite da obrisete!"); return; } int pos = ob.ToString().IndexOf(" "); int idOcena = int.Parse(ob.ToString().Substring(0, pos)); Ocena ocena = s.Get <Ocena>(idOcena); s.Delete(ocena); s.Flush(); s.Close(); MessageBox.Show("Uspesno obrisano ocena!"); lbOcene.Items.Clear(); this.CtrlBrisiOcenu_Load(null, null); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public IActionResult DeleteOcena([FromRoute] int idOceny) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Ocena ocena = _educationSystemData.GetNotes() .FirstOrDefault(ocenaObj => ocenaObj.IdOceny == idOceny); if (ocena == null) { return(NotFound()); } Przedmiot lecture = _educationSystemData.GetLectures() .FirstOrDefault(lectureObj => lectureObj.IdPrzedmiotu == ocena.IdPrzedmiotu); Student student = _educationSystemData.GetStudents() .FirstOrDefault(studentObj => studentObj.Indeks == ocena.Indeks); if (lecture == null || student == null) { return(NotFound()); } _educationSystemData.DeleteStudentNote(student, lecture, ocena); return(Ok()); }
public Ocena SacuvajOcenu(Ocena o) { OpstaSistemskaOperacija sistemskaOperacija = new SacuvajOcenuSO(); sistemskaOperacija.Izvrsi(o); return(((SacuvajOcenuSO)sistemskaOperacija).Ocena); }
public OcenaView GetOcenaViewId(int id) { ISession s = DataLayer.getSession(); Ocena ocena = s.Query <Ocena>().Where(o => o.IdOcene == id).Select(p => p).FirstOrDefault(); return(new OcenaView(ocena)); }
private void Button_Click(object sender, System.Windows.RoutedEventArgs e) { int idU = Int32.Parse(this.b.Text); string ocena = this.bb.Text; int idN = Int32.Parse(this.bbb.Text); int idP = Int32.Parse(this.bbbb.Text); string opis = this.opis.Text; string data = this.data.Text; using var db = new baza(); var nowaOcena = new Ocena { IdUczen = idU, Ocena1 = ocena, Opis = opis, IdNauczyciel = idN, IdPrzedmiot = idP, Data = data }; db.Ocenas.Add(nowaOcena); db.SaveChanges(); }
public IActionResult UpdateStudentNote([FromRoute] int studentIndex, [FromRoute] int lectureIndex, [FromRoute] int noteIndex, [FromBody] Ocena note) { Student student = _educationSystemData.GetStudents() .FirstOrDefault(studentObj => studentObj.Indeks == studentIndex); Przedmiot lecture = _educationSystemData.GetLectures() .FirstOrDefault(lectureObj => lectureObj.Id == lectureIndex); Ocena noteTemp = _educationSystemData.GetNotes() .FirstOrDefault(noteObj => noteObj.Id == noteIndex); if (student == null || lecture == null || note == null) { return(NotFound()); } if (note.Wartosc < 2.0 || note.Wartosc > 5.0) { return(BadRequest()); } noteTemp.Wartosc = note.Wartosc; _educationSystemData.UpdateStudentNote(student, lecture, noteTemp); return(Ok(/*student*/)); }
public async Task <IActionResult> PutOcena(int id, Ocena ocena) { if (id != ocena.ID) { return(BadRequest()); } context.Entry(ocena).State = EntityState.Modified; try { await context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OcenaExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Oceny(int przedmiotID, int uczenID, string opis, string options) { if (Request.Cookies["zalogowanyID"] == null) { // return RedirectToAction("Logowanie", "User"); } if (!Request.Cookies["zalogowanyRola"].Value.Equals("nauczyciel")) { // return Redirect("BrakUprawnien"); } Nauczyciel nauczyciel = db.Nauczyciele.Find(Int32.Parse(Request.Cookies["zalogowanyID"].Value)); Ocena o = new Ocena(); o.nauczycielID = nauczyciel.nauczycielID; o.przedmiotID = przedmiotID; o.uczenID = uczenID; o.opis = opis; o.wartosc = Int32.Parse(options); o.data_wystawienia = DateTime.Now; db.Oceny.Add(o); db.SaveChanges(); return(View(db.listaKlasaPrzedmiot.Where(kp => kp.nauczycielPrzedmiot.nauczycielID == nauczyciel.nauczycielID).Include(kp => kp.klasa).Include(kp => kp.nauczycielPrzedmiot).Include(kp => kp.nauczycielPrzedmiot.przedmiot).Include(l => l.klasa.uczens))); }
// GET: Ocenas/Edit/5 public ActionResult Edit(int?id) { if ((User.IsInRole("Nauczyciel")) || User.IsInRole("Administrator")) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Ocena ocena = db.Ocenas.Find(id); if (ocena == null) { return(HttpNotFound()); } if (User.IsInRole("Nauczyciel")) { string ZalogowanyNauczyciel = Request.ServerVariables["LOGON_USER"]; ViewBag.PrzedmiotID = new SelectList(db.Przedmiots.Where(u => u.przedmiotNauczyciel.Email.Equals(ZalogowanyNauczyciel)), "ID", "NazwaPrzedmiotu", ocena.PrzedmiotID); ViewBag.UczenID = new SelectList(db.Uczens, "ID", "PelnaNazwa", ocena.UczenID); return(View(ocena)); } ViewBag.PrzedmiotID = new SelectList(db.Przedmiots, "ID", "NazwaPrzedmiotu", ocena.PrzedmiotID); ViewBag.UczenID = new SelectList(db.Uczens, "ID", "PelnaNazwa", ocena.UczenID); return(View(ocena)); } else { return(View("~/Views/Uczens/PermissionDenied.cshtml")); } }
public ActionResult Edit([Bind(Include = "ID,WartoscOceny,UczenID,PrzedmiotID")] Ocena ocena) { if ((User.IsInRole("Nauczyciel")) || User.IsInRole("Administrator")) { if (ModelState.IsValid) { db.Entry(ocena).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } if (User.IsInRole("Nauczyciel")) { string ZalogowanyNauczyciel = Request.ServerVariables["LOGON_USER"]; ViewBag.PrzedmiotID = new SelectList(db.Przedmiots.Where(u => u.przedmiotNauczyciel.Email.Equals(ZalogowanyNauczyciel)), "ID", "NazwaPrzedmiotu", ocena.PrzedmiotID); ViewBag.UczenID = new SelectList(db.Uczens, "ID", "PelnaNazwa", ocena.UczenID); return(View(ocena)); } ViewBag.PrzedmiotID = new SelectList(db.Przedmiots, "ID", "NazwaPrzedmiotu", ocena.PrzedmiotID); ViewBag.UczenID = new SelectList(db.Uczens, "ID", "PelnaNazwa", ocena.UczenID); return(View(ocena)); } else { return(View("~/Views/Uczens/PermissionDenied.cshtml")); } }
static void Main(string[] args) { Osoba os = new Osoba("Jacek", "Przepiorka", "13-23-1992"); os.WypiszInfo(); Osoba os1 = new Student("Jacek", "Krzynowek", "22-32-1212", 1, 3, 102232); Osoba os2 = new Pilkarz("Krzysiek", "Bac", "22-33-1111", "Napastnik", "Barcelona", 2); Pilkarz pilkarz = new Pilkarz("Krzysiek", "Bac", "22-33-1111", "Napastnik", "Barcelona", 2); Student student = new Student("Karol", "bielawski", "22-33-1112", 1, 3, 102312); Ocena ocena = new Ocena("historia", "14-12-2018", 3); Ocena ocena2 = new Ocena("historia", "14-12-2018", 4); ((Student)os1).Dodaj(ocena); (student).Dodaj(ocena2); List <Osoba> studencik = new List <Osoba>(); studencik.Add(student); foreach (var item in studencik) { Console.WriteLine(item); } ((Student)student).Dodaj(ocena); (student).Dodaj(ocena2); ((Student)student).Wyswietl(); os1.WypiszInfo(); pilkarz.StrzelGola(); pilkarz.WypiszInfo(); Console.ReadLine(); }
//public IQueryable<Ocena> GetOcenas() //{ // return db.Ocenas; //} //public IEnumerable<Ocena> Get() //{ // return db.Ocenas.ToList(); //} //public JsonResult IndexForMobileApp() //{ // var ListaOcen = db.Ocenas.Include(x => x.OcenaUczen).ToList(); // return Json(ListaOcen, JsonRequestBehavior.AllowGet); //} //[HttpGet] //[Route("findall")] //public HttpResponseMessage findAll() //{ // try // { // var response = new HttpResponseMessage(HttpStatusCode.OK); // //var nauczyciels = db.Ocenas.Include(x => x.OcenaUczen).Select(p => new Nauczyciel // //{ // // ID = p.ID, // // Imie = p.Imie, // // Nazwisko = p.Nazwisko, // // Adres = p.Adres, // // Email = p.Email, // // NumerTelefonu = p.NumerTelefonu, // // PrzedmiotyNauczyciela = p.PrzedmiotyNauczyciela, // //}).ToList(); // response.Content = new StringContent(JsonConvert.SerializeObject(db.Ocenas)); // response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); // return response; // } // catch // { // return new HttpResponseMessage(HttpStatusCode.BadGateway); // } //} // GET: Ocenas/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Ocena ocena = db.Ocenas.Find(id); if (ocena == null) { return(HttpNotFound()); } if (User.IsInRole("Nauczyciel") || User.IsInRole("Administrator")) { return(View(ocena)); } else { string ZalogowanyUczen = Request.ServerVariables["LOGON_USER"]; if (ocena.OcenaUczen.Email == ZalogowanyUczen) { return(View(ocena)); } else { return(View("~/Views/Uczens/PermissionDenied.cshtml")); } } }
public IActionResult GetSaveConcreteNoteFromLecturesStudent([FromRoute] int studentIndex, [FromRoute] int przedmiotIndex, [FromRoute] int noteIndex) { Student student = _educationSystemData.GetStudents() .FirstOrDefault(studentObj => studentObj.Indeks == studentIndex); Przedmiot przedmiot = _educationSystemData.GetLectures() .FirstOrDefault(lectureObj => lectureObj.Id == przedmiotIndex); if (student == null || przedmiot == null) { return(NotFound()); } if (student.Oceny == null || student.Oceny.Count() <= 0) { return(NotFound()); } Ocena ocena = _educationSystemData.GetNotes() .Find(ocenaObj => ocenaObj.Id == noteIndex && ocenaObj.IdStudent == student.Indeks && ocenaObj.IdPrzedmiot == przedmiot.Id); if (ocena == null) { return(NotFound()); } return(Ok(ocena)); }
public Ocena Update(Domain.Education.Ocena domainObject) { OcenaRepository manager = new OcenaRepository(); Ocena siteOceni = manager.Update(domainObject); return(siteOceni); }
public OcenaView(Ocena o) { idOcena = o.IdOcene; Broj = o.Broj; TipOcene = o.TipOcene; Opis = o.Opis; }
public void InsertTest() { Random random = new Random(DateTime.Now.Millisecond); KorisnikManager korisnikMan = new KorisnikManager(); KorisnikCollection siteKorisnici = korisnikMan.GetAll(); int KorisnikID = random.Next(0, siteKorisnici.Count); Korisnik izbranKorisnik = siteKorisnici[KorisnikID]; PredmetManager predmetMan = new PredmetManager(); PredmetCollection sitePredmeti = predmetMan.GetAll(); int PredmetID = random.Next(0, sitePredmeti.Count); Predmet izbranPredmet = sitePredmeti[PredmetID]; Ocena ocena = new Ocena(); ocena.Ocenka = randomOcena(); ocena.student.Id = izbranKorisnik.Id; ocena.predmet.Id = izbranPredmet.Id; OcenaManager manager = new OcenaManager(); Ocena dodadete = manager.Insert(ocena); Assert.IsNotNull(dodadete); Assert.AreEqual(ocena.student.Id, dodadete.student.Id); Assert.AreEqual(ocena.predmet.Id, dodadete.predmet.Id); Assert.AreEqual(ocena.Ocenka, dodadete.Ocenka); Console.WriteLine("Додадена е нова оцена: СтудентИД: {0}, ПредметИД: {1}, Оцена: {2}", dodadete.student.Id, dodadete.predmet.Id, dodadete.Ocenka); }
public void ZmienOcene_DoubleValue_OcenaChanged() { Przedmiot przedmiot = new Przedmiot("Historia"); Ocena ocena = new Ocena(5.0, przedmiot); ocena.ZmienOcene(4.0); Assert.AreEqual(4.0, ocena.wartosc); }
public ActionResult DeleteConfirmed(int id) { Ocena ocena = db.Oceny.Find(id); db.Oceny.Remove(ocena); db.SaveChanges(); return(RedirectToAction("Index")); }
private ActionResult DeleteConfirmed(int id) { Ocena ocena = _context.Ocene.Find(id); _context.Ocene.Remove(ocena); _context.SaveChanges(); return(RedirectToAction("Index")); }
public void ZmienOcene_DoubleValueOutOfRange_NotUpdated() { var przedmiot = new Przedmiot("Chemia"); var ocena = new Ocena(5.0, przedmiot); ocena.ZmienOcene(8.0); Assert.AreEqual(5.0, ocena.wartosc); }
public Komentar(string opis, DateTime datumObjave, string korisnikKojiJeOstavioKomentar, DateTime voznjaNaKojuJeKomentarOstavljen, Ocena ocenaVoznje) { Opis = opis; DatumObjave = datumObjave; KorisnikKojiJeOstavioKomentar = korisnikKojiJeOstavioKomentar; VoznjaNaKojuJeKomentarOstavljen = voznjaNaKojuJeKomentarOstavljen; OcenaVoznje = ocenaVoznje; }
private void ZapiszOcene(Ocena ocena) { context.Entry(ocena).State = EntityState.Modified; try { context.SaveChanges(); } catch (DbUpdateConcurrencyException) { throw; } }