public async Task <IActionResult> Edit(long id, [Bind("ID,courseID,studentID,semester,year,grade,seminalURL,projectURL,examPoints,seminalPoints,projectPoints,additionalPoints,finnishDate")] Enrollment enrollment)
        {
            if (id != enrollment.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(enrollment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EnrollmentExists(enrollment.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["courseID"]  = new SelectList(_context.Course, "ID", "title", enrollment.courseID);
            ViewData["studentID"] = new SelectList(_context.Student, "ID", "fullName", enrollment.studentID);
            return(View(enrollment));
        }
예제 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,Degree,AcademicRank,OfficeNumber,HireDate")] Teacher teacher)
        {
            if (id != teacher.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(teacher);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TeacherExists(teacher.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(teacher));
        }
예제 #3
0
        public async Task <IActionResult> Edit(long id, [Bind("EnrollmentID,CourseID,StudentID,Semester,Grade,Year,SeminalUrl,ProjectUrl,ExamPoints,SeminalPoints,ProjectPoints,AdditionalPoints,FinishDate")] Enrollment enrollment)
        {
            if (id != enrollment.EnrollmentID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(enrollment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EnrollmentExists(enrollment.EnrollmentID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseID"]  = new SelectList(_context.Courses, "CourseID", "Title", enrollment.CourseID);
            ViewData["StudentID"] = new SelectList(_context.Students, "ID", "FullName", enrollment.StudentID);
            return(View(enrollment));
        }
예제 #4
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,FirstName,LastName,AverageScore,GroupId")] Student student)
        {
            if (id != student.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(student);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StudentExists(student.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GroupId"] = new SelectList(_context.Groups, "Id", "Id", student.GroupId);
            return(View(student));
        }
        public async Task <IActionResult> Edit(int id, IFormFile imageUrl, [Bind("ID,firstName,lastName,degree,academicRank,officeNumber,hireDate,profilePicture")] Teacher teacher)
        {
            if (id != teacher.ID)
            {
                return(NotFound());
            }

            TeachersController uploadImage = new TeachersController(_context, webHostEnvironment);

            teacher.profilePicture = uploadImage.UploadedFile(imageUrl);

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(teacher);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TeacherExists(teacher.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Details", new { id = teacher.ID }));
            }
            return(View(teacher));
        }
예제 #6
0
        public async Task <IActionResult> Edit(int id, [Bind("id,NumberCopies,Content,StudentMail")] Paper paper)
        {
            if (id != paper.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(paper);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PaperExists(paper.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(paper));
        }
예제 #7
0
        public async Task <IActionResult> Edit(int id, [Bind("InstructorID,Location")] OfficeAssignment officeAssignment)
        {
            if (id != officeAssignment.InstructorID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(officeAssignment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OfficeAssignmentExists(officeAssignment.InstructorID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["InstructorID"] = new SelectList(_context.Instructors, "ID", "FirstMidName", officeAssignment.InstructorID);
            return(View(officeAssignment));
        }
예제 #8
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Grade,StudentId,CourseId")] Enrollment enrollment)
        {
            if (id != enrollment.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(enrollment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EnrollmentExists(enrollment.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseId"]  = new SelectList(_context.Course, "Id", "Id", enrollment.CourseId);
            ViewData["StudentId"] = new SelectList(_context.Student, "Id", "Id", enrollment.StudentId);
            return(View(enrollment));
        }
        public async Task <IActionResult> Edit(int id, [Bind("CourseID,Title,Credits,DepartmentID")] Course course)
        {
            if (id != course.CourseID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(course);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CourseExists(course.CourseID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            PopulateDepartmentsDropDownList(course.DepartmentID);
            return(View(course));
        }
예제 #10
0
        public async Task <IActionResult> Edit(int id, [Bind("id,Studentid,Faculty,Course,Note")] StudentData studentData)
        {
            if (id != studentData.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(studentData);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StudentDataExists(studentData.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(studentData));
        }
예제 #11
0
        public async Task <IActionResult> Edit(int id, [Bind("TeacherID,FullName,Position,Phone")] Teacher teacher)
        {
            if (id != teacher.TeacherID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(teacher);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TeacherExists(teacher.TeacherID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(teacher));
        }
예제 #12
0
        public async Task <IActionResult> Edit(long id, [Bind("Id,DayId,GroupId")] Shedule shedule)
        {
            if (id != shedule.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(shedule);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SheduleExists(shedule.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DayId"]   = new SelectList(_context.Days, "Id", "Name", shedule.DayId);
            ViewData["GroupId"] = new SelectList(_context.Groups, "Id", "Name", shedule.GroupId);
            return(View(shedule));
        }
예제 #13
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Email,AddressId")] Student student)
        {
            if (id != student.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(student);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StudentExists(student.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AddressId"] = new SelectList(_context.Set <Address>(), "Id", "Id", student.AddressId);
            return(View(student));
        }
예제 #14
0
        public async Task <IActionResult> Edit(int id, [Bind("DepartmentID,Name,Budget,StartDate,InstructorID")] Department department)
        {
            if (id != department.DepartmentID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(department);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DepartmentExists(department.DepartmentID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["InstructorID"] = new SelectList(_context.Instructors, "ID", "FirstMidName", department.InstructorID);
            return(View(department));
        }
예제 #15
0
        public async Task <IActionResult> Edit(long id, [Bind("Id,StudentId,FirstName,LastName,EnrollmentDate,AcquiredCredits,CurrentSemester,EducationLevel")] Student student)
        {
            if (id != student.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(student);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StudentExists(student.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(student));
        }
예제 #16
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Avatar,FirstName,LastName,Email")] Student student)
        {
            if (id != student.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    db.Update(student);
                    await db.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StudentExists(student.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(student));
        }
예제 #17
0
        public async Task <IActionResult> Edit(int id, [Bind("EnrollmentID,CourseID,StudentID,Grade")] Enrollment enrollment)
        {
            if (id != enrollment.EnrollmentID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(enrollment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EnrollmentExists(enrollment.EnrollmentID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseID"]  = new SelectList(_context.Courses, "CourseID", /*"CourseID"*/ "Title", enrollment.CourseID);
            ViewData["StudentID"] = new SelectList(_context.Students, "ID", /*"ID"*/ "FirstMidName", enrollment.StudentID);
            return(View(enrollment));
        }
        public async Task <IActionResult> Edit(long id, IFormFile imageUrl, StudentCreateViewModel model, [Bind("ID,studentID,firstName,lastName,enrollmentDate,acquiredCredits,currentSemestar,educationLevel,profilePicture")] Student student)
        {
            if (id != student.ID)
            {
                return(NotFound());
            }

            StudentsController uploadImage = new StudentsController(_context, webHostingEnvironment);

            student.profilePicture = uploadImage.UploadedFile(imageUrl);

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(student);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StudentExists(student.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Details", new { id = student.ID }));
            }
            return(View(student));
        }
예제 #19
0
        public override void Execute()
        {
            try
            {
                using (var universityContext = new UniversityContext())
                {
                    var people1
                        = universityContext.People
                          .ToList();

                    if (people1.Count != 1)
                    {
                        throw new TestCaseFailureException(
                                  "Result set 1's cardinality is incorrect.\n" + people1.Count + " != 1");
                    }

                    var person_actual1
                        = people1
                          .First();

                    person_actual1.Age          = 30;
                    person_actual1.Name         = "Test Person 1 2";
                    person_actual1.PlaceOfBirth = "Test City 1 2";

                    universityContext
                    .Update(
                        person_actual1);

                    universityContext
                    .SaveChanges();

                    var people2
                        = universityContext.People
                          .ToList();

                    if (people2.Count != 1)
                    {
                        throw new TestCaseFailureException(
                                  "Result set 2's cardinality is incorrect.\n" + people2.Count + " != 1");
                    }

                    var person_actual2
                        = people2
                          .First();

                    if (person_actual2.Age != person_actual1.Age || person_actual2.Name != person_actual1.Name || person_actual2.PlaceOfBirth != person_actual1.PlaceOfBirth)
                    {
                        throw new TestCaseFailureException(
                                  "Modified result entity's properties are not perfect.");
                    }
                }
            }
            catch (Exception e)
            {
                throw new TestCaseFailureException(
                          "Exception catched:\n" + e.Message + ((e.InnerException != null)
                        ? "\n\tInner exception:\n\t\t" + e.InnerException.Message
                        : ""));
            }
        }
예제 #20
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Author,Price")] Book book)
        {
            if (id != book.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(book);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BookExists(book.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(book));
        }
        public async Task <IActionResult> Edit(int id, [Bind("DisciplineID,NameDiscipline,NumberOfHoursOfLectures,NumberOfHoursOfPractice,TypeOfRporting,TeacherID,TypeOfDisciplineID,SpecialtyID")] Discipline discipline)
        {
            if (id != discipline.DisciplineID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(discipline);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DisciplineExists(discipline.DisciplineID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SpecialtyID"]        = new SelectList(_context.Speciaties, "SpecialtyID", "NameSpecialty", discipline.SpecialtyID);
            ViewData["TeacherID"]          = new SelectList(_context.Teachers, "TeacherID", "FullName", discipline.TeacherID);
            ViewData["TypeOfDisciplineID"] = new SelectList(_context.TypeOfDisciplins, "TypeOfDisciplineID", "NameTypeOfDiscipline", discipline.TypeOfDisciplineID);
            return(View(discipline));
        }
예제 #22
0
        public async Task <IActionResult> Edit(int id, [Bind("SpecialtyID,NameSpecialty,PulpitID,Course,Semester")] Specialty specialty)
        {
            if (id != specialty.SpecialtyID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(specialty);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SpecialtyExists(specialty.SpecialtyID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PulpitID"] = new SelectList(_context.Pulpits, "PulpitID", "NamePulpit", specialty.PulpitID);
            return(View(specialty));
        }
        public async Task <IActionResult> Edit(int id, [Bind("TypeOfDisciplineID,NameTypeOfDiscipline")] TypeOfDiscipline typeOfDiscipline)
        {
            if (id != typeOfDiscipline.TypeOfDisciplineID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(typeOfDiscipline);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TypeOfDisciplineExists(typeOfDiscipline.TypeOfDisciplineID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(typeOfDiscipline));
        }
예제 #24
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Credits,Semester,Programme,EducationLevel,FirstTeacherId,SecondTeacherId")] Course course)
        {
            if (id != course.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(course);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CourseExists(course.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FirstTeacherId"]  = new SelectList(_context.Set <Teacher>(), "Id", "FullName", course.FirstTeacherId);
            ViewData["SecondTeacherId"] = new SelectList(_context.Set <Teacher>(), "Id", "FullName", course.SecondTeacherId);
            return(View(course));
        }
예제 #25
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,Name,AverageScore,CourseId,SpecialtyId")] Group @group)
        {
            if (id != @group.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(@group);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GroupExists(@group.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseId"]    = new SelectList(_context.Courses, "Id", "Id", @group.CourseId);
            ViewData["SpecialtyId"] = new SelectList(_context.Specialties, "Id", "Id", @group.SpecialtyId);
            return(View(@group));
        }
예제 #26
0
        public async Task <IActionResult> Edit(int id, [Bind("FacultyID,NameFaculty")] Faculty faculty)
        {
            if (id != faculty.FacultyID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(faculty);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FacultyExists(faculty.FacultyID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(faculty));
        }
예제 #27
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,Value,SubjectId,StudentId,CourseId")] Score score)
        {
            if (id != score.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(score);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ScoreExists(score.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CourseId"]  = new SelectList(_context.Courses, "Id", "Id", score.CourseId);
            ViewData["StudentId"] = new SelectList(_context.Students, "Id", "Id", score.StudentId);
            ViewData["SubjectId"] = new SelectList(_context.Subjects, "Id", "Id", score.SubjectId);
            return(View(score));
        }
예제 #28
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Title")] Course course)
        {
            if (id != course.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(course);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CourseExists(course.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(course));
        }
예제 #29
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,LastName,FirstMidName,EnrollmentDate")] Student student)
        {
            if (id != student.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(student);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StudentExists(student.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(student));
        }
예제 #30
0
        public async Task <IActionResult> Edit(int id, [Bind("PulpitID,NamePulpit,KindOfChair,FacultyID")] Pulpit pulpit)
        {
            if (id != pulpit.PulpitID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(pulpit);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PulpitExists(pulpit.PulpitID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["FacultyID"] = new SelectList(_context.Faculties, "FacultyID", "NameFaculty", pulpit.FacultyID);
            return(View(pulpit));
        }