public async Task <IActionResult> Edit(int id, [Bind("Id,SpecialtyId,Name,FormationYear")] AcademicGroup 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["SpecialtyId"] = new SelectList(_context.Specialties.OrderBy(c => c.Code).Select(x => new SelectListItem {
                Text = $"{x.Code} - {x.Name}", Value = x.Code
            }), "Value", "Text");
            return(View(group));
        }
        public async Task <IActionResult> Approve(int id, [Bind("Id")] TeacherRequest teacherRequest, string returnUrl)
        {
            if (id != teacherRequest.Id || !TeacherRequestExists(id))
            {
                return(NotFound());
            }

            var tR = await _context.TeacherRequests.Include(x => x.GraduationWork).Include(x => x.Teacher).FirstOrDefaultAsync(x => x.Id == id);

            tR.Approve(tR.Teacher);

            _context.Update(tR);
            await _context.SaveChangesAsync();

            return(RedirectToUrl(returnUrl));
        }
Esempio n. 3
0
        public async Task <IActionResult> Edit(string id, [Bind("Code,AcademicDegree,Name")] Specialty specialty)
        {
            if (id != specialty.Code)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(specialty);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SpecialtyExists(specialty.Code))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(specialty));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Discipline discipline, string returnUrl, int?groupId = null)
        {
            if (id != discipline.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(discipline);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DisciplineExists(discipline.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Details), new { id = id, returnUrl = returnUrl, groupId = groupId }));
            }

            ViewData["groupId"]   = groupId;
            ViewData["returnUrl"] = returnUrl;
            return(View(discipline));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,SchedulePlanId,EventDescription,Date,Class,ResponsibleTeacherId")] Event @event)
        {
            if (id != @event.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(@event);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EventExists(@event.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ResponsibleTeacherId"] = new SelectList(_context.Teachers, "Id", "FullName", @event.ResponsibleTeacherId);
            ViewData["SchedulePlanId"]       = new SelectList(_context.SchedulePlans, "Id", "Id", @event.SchedulePlanId);
            return(View(@event));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,FullName,Post,AcademicDegree")] Teacher teacher, string ReturnUrl)
        {
            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(Details), new { id, ReturnUrl }));
            }
            ViewData["ReturnUrl"] = ReturnUrl;
            return(View(teacher));
        }
Esempio n. 7
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,StudentId,Theme,ScientificAdviserId,ReviewerId")] GraduationWork graduationWork)
        {
            if (id != graduationWork.Id || !GraduationWorkExists(id))
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                _context.Update(graduationWork);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["StudentId"]           = new SelectList(_context.Students, "GradebookNumber", "FullName", graduationWork.StudentId);
            ViewData["ScientificAdviserId"] = new SelectList(_context.Teachers, "Id", "FullName", graduationWork.ScientificAdviserId);
            ViewData["ReviewerId"]          = new SelectList(_context.Teachers, "Id", "FullName", graduationWork.ReviewerId);
            return(View(graduationWork));
        }
        public async Task <IActionResult> Approve(int id, bool students, bool teachers, bool advisers)
        {
            if (SchedulePlanExists(id))
            {
                SchedulePlan schedulePlan = await _context.SchedulePlans.FindAsync(id);

                String name = User.Identity.Name;
                User   user = await _userManager.FindByNameAsync(name);

                schedulePlan.Approve(user.SecondName + " " + user.FirstName[0] + "." + user.MiddleName?[0] +".", DateTime.Now);
                _context.Update(schedulePlan);
                await _context.SaveChangesAsync();

                await MailingAsync(id, students, teachers, advisers);

                return(RedirectToAction(nameof(Index)));
            }
            return(NotFound());
        }
Esempio n. 9
0
        public async Task <IActionResult> Protect(int?id, [Bind("Id,StudentId,ActivityId,Points")] ActivityProtection activityProtection, string ReturnUrl, int?groupId)
        {
            if (ModelState.IsValid)
            {
                if (activityProtection.Points > _context.Activities.Find(activityProtection.ActivityId).MaxPoints || activityProtection.Points < 0)
                {
                    ModelState.AddModelError($"student-{activityProtection.StudentId}", "Оценка должна быть в диапозоне от 0 до " + _context.Activities.Find(activityProtection.ActivityId).MaxPoints);
                }

                activityProtection.ProtectionDate = DateTime.Now;
                if (_context.ActivityProtections.Any(x => x.ActivityId == activityProtection.ActivityId && x.StudentId == activityProtection.StudentId))
                {
                    try
                    {
                        _context.Update(activityProtection);
                        await _context.SaveChangesAsync();
                    }
                    catch (DbUpdateConcurrencyException)
                    {
                        if (!ActivityProtectionExists(activityProtection.Id))
                        {
                            return(NotFound());
                        }
                        else
                        {
                            throw;
                        }
                    }
                }
                else
                {
                    activityProtection.Id = 0;
                    _context.Add(activityProtection);
                    await _context.SaveChangesAsync();
                }
            }

            ViewData["groupId"]   = groupId;
            ViewData["ReturnUrl"] = ReturnUrl;
            return(RedirectToAction(nameof(Protect), new { id = id, groupId = groupId }));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,DisciplineId,Year,Semester,ControlType")] SemesterDiscipline semesterDiscipline, string returnUrl)
        {
            if (id != semesterDiscipline.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(semesterDiscipline);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SemesterDisciplineExists(semesterDiscipline.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }

                if (!string.IsNullOrEmpty(returnUrl) && Url.IsLocalUrl(returnUrl))
                {
                    return(Redirect(returnUrl));
                }
                else
                {
                    return(RedirectToAction("Details", "Disciplines", new { id = semesterDiscipline.DisciplineId }));
                }
            }
            ViewData["returnUrl"]    = returnUrl;
            ViewData["DisciplineId"] = new SelectList(_context.Disciplines, "Id", "Name", semesterDiscipline.DisciplineId);
            return(View(semesterDiscipline));
        }
        public async Task <IActionResult> Edit(int id, [Bind("GradebookNumber,GroupId,FullName,PhoneNumber")] Student student, string ReturnUrl)
        {
            if (id != student.GradebookNumber)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(student);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StudentExists(student.GradebookNumber))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                if (!string.IsNullOrEmpty(ReturnUrl) && Url.IsLocalUrl(ReturnUrl))
                {
                    return(RedirectToAction(nameof(Details), new { id = id, ReturnUrl = ReturnUrl }));
                }
                else
                {
                    return(RedirectToAction(nameof(Details), new { id = id }));
                }
            }
            ViewData["GroupId"]   = new SelectList(_context.AcademicGroups, "Id", "Name", student.GroupId);
            ViewData["ReturnUrl"] = ReturnUrl;
            return(View(student));
        }
Esempio n. 12
0
        public async Task <IActionResult> Edit([Bind("Id,SemesterDisciplineId,GroupId,Number,CompletionDate")] RatingControl ratingControl)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(ratingControl);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RatingControlExists(ratingControl.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
            }

            return(RedirectToAction(nameof(Details), new { id = ratingControl.Id }));
        }