public static PupilModel ToModel(Pupils pupil) { return(new PupilModel { Id = pupil.Id, FirstName = pupil.FirstName, LastName = pupil.LastName, BirthdayDate = pupil.BirthdayDate, ClassroomId = pupil.Classroom_Id, Classrooms = pupil.Classrooms.Title, Levels = pupil.Levels.Title, LevelId = pupil.Level_Id, State = pupil.State, Tutor = pupil.Tutors.FirstName + " " + pupil.Tutors.LastName, TutorId = pupil.Tutor_Id, Sex = (Gender)pupil.Sex, Results = pupil.Results.Select(r => new ResultListByPupil { Evaluation = new ModelWithNameAndId { Id = r.Evaluations.Id, Name = r.Evaluations.Classrooms.Title + " - " + r.Evaluations.Date.ToShortDateString() }, Result = new ModelWithNameAndId { Id = r.Id, Name = r.Note.ToString() } }) }); }
public ActionResult DeleteEleve(Guid id) { EleveModels model; using (EleveRepository repository = new EleveRepository()) { Pupils x = repository.GetPupilById(id); if (x == null) { return(HttpNotFound()); } model = new EleveModels { id = x.Id, firstName = x.FirstName, lastName = x.LastName, sexe = x.Sex, birthdayDate = x.BirthdayDate, tuteurId = x.Tutor_Id, classroomId = x.Classroom_Id, levelId = x.Level_Id // tuteurs = // classroom = // level = // result = }; } return(View("DeleteEleve", model)); }
private void pupilsButton_Main_Click(object sender, EventArgs e) { Pupils pupils = new Pupils(user, status); pupils.Show(); this.Hide(); }
public ActionResult CreateEleve(EleveModels model) { if (ModelState.IsValid) { using (EleveRepository repository = new EleveRepository()) { Pupils a = new Pupils { Id = Guid.NewGuid(), State = short.MaxValue, FirstName = model.firstName, LastName = model.lastName, Sex = model.sexe, BirthdayDate = model.birthdayDate, Tutor_Id = model.tuteurId, Classroom_Id = model.classroomId, Level_Id = model.levelId // tuteurs = // classroom = // level = // result = }; repository.Add(a); repository.Save(); } return(RedirectToAction("ReadEleves")); } return(View(model)); }
public ActionResult AddOrUpdate(PupilModel model) { if (!ModelState.IsValid) { return(View(model)); } var isCreated = model.Id == Guid.Empty; var pupil = new Pupils(); if (!isCreated) { pupil = PupilRepository.GetById(model.Id); } pupil.BirthdayDate = model.BirthdayDate; pupil.Classrooms = ClassroomRepository.GetById(pupil.Classroom_Id); pupil.Classroom_Id = model.ClassroomId; pupil.FirstName = model.FirstName; pupil.LastName = model.LastName; pupil.Level_Id = model.LevelId; pupil.Levels = LevelRepository.GetById(pupil.Level_Id); pupil.Sex = (short)model.Sex; pupil.State = model.State; pupil.Tutor_Id = model.TutorId; pupil.Tutors = TutorRepository.GetById(pupil.Tutor_Id); if (isCreated) { PupilRepository.Add(pupil); } PupilRepository.Save(); return(Redirect(Url.Action("Get", "Pupil", new { id = pupil.Id }))); }
public ActionResult ReadEleve(Guid id) { EleveModels model; using (EleveRepository repository = new EleveRepository()) { Pupils x = repository.GetPupilById(id); IQueryable <Tutors> t = repository.GetTutors(); IQueryable <Results> r = repository.GetResultatsByPupilId(id); IQueryable <Evaluations> e = repository.GetEvaluations(); if (x == null) { return(HttpNotFound()); } model = new EleveModels { id = x.Id, firstName = x.FirstName, lastName = x.LastName, sexe = x.Sex, birthdayDate = x.BirthdayDate, tuteurId = x.Tutor_Id, classroomId = x.Classroom_Id, levelId = x.Level_Id, tuteurName = x.Tutors.LastName, classTitle = x.Classrooms.Title, niveauName = x.Levels.Title, resultats = getListResultats(r), evaluations = getListEvaluations(e) }; } return(View(model)); }
public ActionResult EditEleve(Guid id) { EleveModels model; using (EleveRepository repository = new EleveRepository()) { IQueryable <Tutors> tuteurs = repository.GetTutors(); IQueryable <Classrooms> classes = repository.GetClasses(); IQueryable <Levels> niveaux = repository.GetNiveaux(); Pupils x = repository.GetPupilById(id); model = new EleveModels { mode = 0, state = short.MaxValue, firstName = x.FirstName, lastName = x.LastName, sexe = x.Sex, birthdayDate = x.BirthdayDate, tuteurId = x.Tutor_Id, classroomId = x.Classroom_Id, levelId = x.Level_Id, tuteurs = getListTuteurs(tuteurs), classes = getListClasses(classes), niveaux = getListNiveaux(niveaux) }; } return(View("CreateEleve", model)); }
public IndexViewModel(List <List <List <Timetables> > > tt, Pupils p, DateTime d) { timetable = tt; pupil = p; date = d; }
public ActionResult DeleteConfirmed(Guid id) { Pupils pupils = pupilsRepository.GetById(id); pupilsRepository.Remove(pupils); pupilsRepository.Save(); return(RedirectToAction("Index")); }
public IActionResult IsLoginUnique(Pupils pupil) { if (_context.Pupils.Any(p => p.Login == pupil.Login && p.PupilId != pupil.PupilId)) { return(Json(false)); } return(Json(true)); }
public ActionResult DeleteConfirmed(long id) { Pupils pupils = db.Pupils.Find(id); db.Pupils.Remove(pupils); db.SaveChanges(); return(RedirectToAction("Index")); }
private IndexViewModel GetIndexViewModel(int pupilid) { Pupils pupil = _context.Pupils .Where(p => p.PupilId == pupilid) .FirstOrDefault(); Grades grade = _context.Pupils .Include(p => p.Grade) .Where(p => p.PupilId == pupilid) .Select(g => g.Grade) .FirstOrDefault(); List <Groups> groups = _context.GroupPupil .Include(gp => gp.Group) .Include(gp => gp.Pupil) .Where(gp => gp.Pupil.PupilId == pupilid) .Select(gp => gp.Group) .ToList(); var tt = _context.Timetables .Include(t => t.TeacherSubjectGroup) .Include(t => t.TeacherSubjectGroup.TeacherSubject) .Include(t => t.TeacherSubjectGroup.TeacherSubject.Subject) .Include(t => t.TeacherSubjectGroup.TeacherSubject.Teacher) .Include(t => t.TeacherSubjectGroup.Group) .Include(t => t.TeacherSubjectGroup.Group.GroupType) .Include(t => t.TeacherSubjectGroup.Group.Grade) .Where(t => t.TeacherSubjectGroup.Group.GradeId == grade.GradeId) .Where(t => t.TeacherSubjectGroup.Group.GroupTypeId == null || groups.Contains(t.TeacherSubjectGroup.Group)) .OrderBy(t => t.TeacherSubjectGroup.Group.GradeId) .ThenBy(t => t.WeekDayNumber) .ThenBy(t => t.LessonNumber) .ThenBy(t => t.TeacherSubjectGroup.GroupId) .ToList(); int maxLessonNumber = tt.Select(t => t.LessonNumber).DefaultIfEmpty().Max(); List <List <List <Timetables> > > lessons = new List <List <List <Timetables> > >(maxLessonNumber); for (int i = 0; i < maxLessonNumber; i++) { lessons.Add(new List <List <Timetables> >(5)); for (int j = 0; j < 5; j++) { lessons[i].Add(new List <Timetables>()); } } foreach (var lesson in tt) { lessons[lesson.LessonNumber - 1][lesson.WeekDayNumber - 1].Add(lesson); } return(new IndexViewModel(lessons, pupil, DateTime.Now)); }
public ActionResult Edit([Bind(Include = "Id,Pupils_first_name,Pupils_middle_name,Pupils_last_name,Gender,Address,Phone_number,Email")] Pupils pupils) { if (ModelState.IsValid) { db.Entry(pupils).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(pupils)); }
private void button1_Click(object sender, EventArgs e) { Pupils pupils = new Pupils(); pupils.id = 1; pupils.Name = "Naib"; pupils.Surname = "Reshidov"; pupils.ScholNum = "11"; XmlSeralize.Seralize(pupils, "Main"); }
public ActionResult Create([Bind(Include = "Id,Pupils_first_name,Pupils_middle_name,Pupils_last_name,Gender,Address,Phone_number,Email")] Pupils pupils) { if (ModelState.IsValid) { db.Pupils.Add(pupils); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(pupils)); }
public ActionResult Edit([Bind(Include = "Id,FirstName,LastName,Sex,BirthdayDate,State,Tutor_Id,Classroom_Id,Level_Id")] Pupils pupils) { if (ModelState.IsValid) { pupilsRepository.SetEntryState(pupils, EntityState.Modified); pupilsRepository.Save(); return(RedirectToAction("Index")); } ViewBag.Classroom_Id = new SelectList(pupilsRepository.GetAcademy().Classrooms, "Id", "Title", pupils.Classroom_Id); ViewBag.Level_Id = new SelectList(pupilsRepository.GetAcademy().Levels, "Id", "Title", pupils.Level_Id); ViewBag.Tutor_Id = new SelectList(pupilsRepository.GetAcademy().Tutors, "Id", "LastName", pupils.Tutor_Id); return(View(pupils)); }
// GET: Pupils/Edit/5 public ActionResult Edit(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Pupils pupils = db.Pupils.Find(id); if (pupils == null) { return(HttpNotFound()); } return(View(pupils)); }
public ActionResult Details(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Pupils pupils = pupilsRepository.GetById(id); if (pupils == null) { return(HttpNotFound()); } return(View(pupils)); }
public static PupilModel ToModelP(this Pupils p) { { return(new PupilModel() { Id = p.Id, Name = p.Name, Surname = p.Surname, Birthyear = p.Birthyear, ClassNumber = p.ClassNumber, AverageGrade = Math.Round(GradeManager.Average(p.Name, p.Surname), 1) }); } }
public ActionResult Edit([Bind(Include = "Id,FirstName,LastName,Sex,BirthdayDate,State,Tutor_Id,Classroom_Id,Level_Id")] Pupils pupils) { if (ModelState.IsValid) { _pupilRepository.UpdatePupil(pupils); // db.Entry(pupils).State = EntityState.Modified; _pupilRepository.Save(); //db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Classroom_Id = new SelectList(_pupilRepository.GetClassroom(), "Id", "Title", pupils.Classroom_Id); ViewBag.Level_Id = new SelectList(_pupilRepository.GetLevels(), "Id", "Title", pupils.Level_Id); ViewBag.Tutor_Id = new SelectList(_pupilRepository.GetTutors(), "Id", "LastName", pupils.Tutor_Id); return(View(pupils)); }
// GET: Pupils/Delete/5 public ActionResult Delete(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Pupils pupils = _pupilRepository.GetPupilByID(id); //Pupils pupils = db.Pupils.Find(id); if (pupils == null) { return(HttpNotFound()); } return(View(pupils)); }
public ActionResult Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Pupils pupils = pupilsRepository.GetById(id); if (pupils == null) { return(HttpNotFound()); } ViewBag.Classroom_Id = new SelectList(pupilsRepository.GetAcademy().Classrooms, "Id", "Title", pupils.Classroom_Id); ViewBag.Level_Id = new SelectList(pupilsRepository.GetAcademy().Levels, "Id", "Title", pupils.Level_Id); ViewBag.Tutor_Id = new SelectList(pupilsRepository.GetAcademy().Tutors, "Id", "LastName", pupils.Tutor_Id); return(View(pupils)); }
public ActionResult Create([Bind(Include = "Id,FirstName,LastName,Sex,BirthdayDate,State,Tutor_Id,Classroom_Id,Level_Id")] Pupils pupils) { if (ModelState.IsValid) { pupils.Id = Guid.NewGuid(); _pupilRepository.InsertPupil(pupils); _pupilRepository.Save(); //db.Pupils.Add(pupils); //db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Classroom_Id = new SelectList(_pupilRepository.GetClassroom(), "Id", "Title", pupils.Classroom_Id); ViewBag.Level_Id = new SelectList(_pupilRepository.GetLevels(), "Id", "Title", pupils.Level_Id); ViewBag.Tutor_Id = new SelectList(_pupilRepository.GetTutors(), "Id", "LastName", pupils.Tutor_Id); return(View(pupils)); }
// GET: Pupils/Edit/5 public ActionResult Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Pupils pupils = _pupilRepository.GetPupilByID(id); // Pupils pupils = db.Pupils.Find(id); if (pupils == null) { return(HttpNotFound()); } ViewBag.Classroom_Id = new SelectList(_pupilRepository.GetClassroom(), "Id", "Title", pupils.Classroom_Id); ViewBag.Level_Id = new SelectList(_pupilRepository.GetLevels(), "Id", "Title", pupils.Level_Id); ViewBag.Tutor_Id = new SelectList(_pupilRepository.GetTutors(), "Id", "LastName", pupils.Tutor_Id); return(View(pupils)); }
public Pupil Login(string userName, string password) { //Call repository to authenticate pupil into library system //Mocked return assuming password check success var id = Guid.NewGuid(); return(Pupils.GetOrAdd(id, (i) => { //Replace with function to get student info return new Pupil { Id = i, Name = "Bac Clunky", UserName = userName }; })); }
public void AddNewUserPupil(string name, string surnam, string patr, string phone, int?idschool, string email, string password, int number) // добавление нового пользователя ученик { Pupils tmp = new Pupils(); using (EducationSystemContext esc = new EducationSystemContext()) { tmp.Name = name; tmp.Surname = surnam; tmp.Patronymic = patr; tmp.Phone = phone; tmp.Idschool = idschool; tmp.NamberClass = number; tmp.Email = email; tmp.Password = password; tmp.Code = 1000; esc.Pupils.Add(tmp); esc.SaveChanges(); } }
public async Task <IActionResult> Edit(int id, [Bind("PupilId,FirstName,SurName,Patronymic,Dob,GradeId,Login,Password")] Pupils pupils) { if (id != pupils.PupilId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(pupils); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PupilsExists(pupils.PupilId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["GradeId"] = new SelectList(_context.GradesInfo, "GradeId", "GradeName", pupils.GradeId); return(View(pupils)); #region SQL /* * * UPDATE INTO pupils SET FirstName = @FirstName, SurName = @SurName, Patronymic = @Patronymic, Dob = @Dob, GradeId = @GradeId, Login = @Login, Password = @Password * WHERE PupilId = @PupilId; * */ #endregion }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "image/jpg"; string photo = Pupils.getPhoto(context.Request.QueryString["upn"]); if (string.IsNullOrEmpty(photo)) { Bitmap nopic = new Bitmap(142, 183); Graphics gfx = Graphics.FromImage(nopic); gfx.Clear(Color.White); gfx.DrawString("Picture Not Found", SystemFonts.MessageBoxFont, new SolidBrush(Color.DarkRed), 35, 20); gfx.DrawString("The student does not have a picture", SystemFonts.MessageBoxFont, SystemBrushes.WindowText, new RectangleF(5, 60, 137, 40)); MemoryStream mem = new MemoryStream(); nopic.Save(mem, ImageFormat.Jpeg); mem.WriteTo(context.Response.OutputStream); } else { Byte[] b = Base64Encoder.FromBase64(photo); context.Response.OutputStream.Write(b, 0, b.Length); } }
public ActionResult EditEleve(EleveModels model) { using (EleveRepository repository = new EleveRepository()) { Pupils x = repository.GetPupilById(model.id); x.State = short.MaxValue; x.FirstName = model.firstName; x.LastName = model.lastName; x.Sex = model.sexe; x.BirthdayDate = model.birthdayDate; x.Tutor_Id = model.tuteurId; x.Classroom_Id = model.classroomId; x.Level_Id = model.levelId; // eleves = if (ModelState.IsValid) { repository.Save(); } return(RedirectToAction("ReadEleves")); } }
public async Task <IActionResult> Create([Bind("PupilId,FirstName,SurName,Patronymic,Dob,GradeId,Login,Password")] Pupils pupils) { if (ModelState.IsValid) { _context.Add(pupils); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["GradeId"] = new SelectList(_context.Grades, "GradeId", "Letter", pupils.GradeId); return(View(pupils)); #region SQL /* * * INSERT INTO pupils(FirstName,SurName,Patronymic,Dob,GradeId,Login,Password) * VALUES(@FirstName,@SurName,@Patronymic,@Dob,@GradeId,@Login,@Password) * */ #endregion }