示例#1
0
        public async Task <IActionResult> Edit(int id, int cathedraID, [Bind("Id,GroupName,TypeOfStudying")] Group @group)
        {
            @group.CathedraId = cathedraID;
            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("Index", "Groups1", new { id = cathedraID, name = _context.Cathedras.Where(c => c.Id == cathedraID).FirstOrDefault().CathedraName }));
            //    return RedirectToAction(nameof(Index));
            // }
            //  ViewData["CathedraId"] = new SelectList(_context.Cathedras, "Id", "Id", @group.CathedraId);
            // return View(@group);
        }
示例#2
0
        public async Task <IActionResult> Edit(int id, int sessionID, [Bind("Id,SessionId,ExamId")] Schedule schedule)
        {
            if (id != schedule.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(schedule);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ScheduleExists(schedule.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index", "Schedules1", new { id = sessionID }));
                //   return RedirectToAction(nameof(Index));
            }
            return(RedirectToAction("Index", "Schedules1", new { id = sessionID }));
            //  ViewData["ExamId"] = new SelectList(_context.Exams, "Id", "Id", schedule.ExamId);
            //ViewData["SessionId"] = new SelectList(_context.Sessions, "Id", "Id", schedule.SessionId);
            //  return View(schedule);
        }
示例#3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,GroupName,TypeOfStudying,CathedraId")] 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["CathedraId"] = new SelectList(_context.Cathedras, "Id", "CathedraName", @group.CathedraId);
            return(View(@group));
        }
        public async Task <IActionResult> Edit(int id, int facultyID, [Bind("Id,CathedraName")] Cathedras cathedras)
        {
            /*  var elements = _context.Cathedras.ToArray();
             * foreach (var c in elements)
             * {
             *    if (cathedras.CathedraName == c.CathedraName)
             *    {
             *        ModelState.AddModelError("CathedraName", "Coppy Error");
             *        return View(cathedras);
             *    }
             * } */

            cathedras.FacultyId = facultyID;
            if (id != cathedras.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cathedras);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CathedrasExists(cathedras.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                // return RedirectToAction(nameof(Index));
                //    return RedirectToAction("Index", "Cathedras", new { id = facultyID, name = _context.Faculties.Where(c => c.Id == facultyID).FirstOrDefault() });
                return(RedirectToAction("Index", "Cathedras", new { id = facultyID, name = _context.Faculties.Where(c => c.Id == facultyID).FirstOrDefault().FacultyName }));
            }
            // ViewData["FacultyId"] = new SelectList(_context.Faculties, "Id", "Id", cathedras.FacultyId);
            //return View(cathedras);
            return(RedirectToAction("Index", "Cathedras", new { id = facultyID, name = _context.Faculties.Where(c => c.Id == facultyID).FirstOrDefault().FacultyName }));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,GroupId,SessionName")] Sessions sessions)
        {
            var elements = _context.Sessions.ToArray();

            foreach (var c in elements)
            {
                if ((sessions.SessionName == c.SessionName) && (sessions.GroupId == sessions.GroupId))
                {
                    ViewData["GroupId"] = new SelectList(_context.Group, "Id", "GroupName");
                    ModelState.AddModelError("SessionName", "Coppy Error");
                    return(View(sessions));
                }
            }

            if (id != sessions.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(sessions);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SessionsExists(sessions.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GroupId"] = new SelectList(_context.Group, "Id", "GroupName", sessions.GroupId);
            return(View(sessions));
        }
示例#6
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Surname,BirthDay,GroupId")] Aspirant aspirant)
        {
            if (id != aspirant.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                DateTime time_now = DateTime.Now;
                DateTime d1       = new DateTime(2020, 1, 20, 6, 20, 40);
                DateTime d2       = aspirant.BirthDay.Value;
                if (DateTime.Compare(time_now, d2) <= 0)
                {
                    ModelState.AddModelError("BirthDay", "BirthDay Error");
                    ViewData["GroupId"] = new SelectList(_context.Group, "Id", "GroupName", aspirant.GroupId);
                    return(View(aspirant));
                }



                try
                {
                    _context.Update(aspirant);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AspirantExists(aspirant.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GroupId"] = new SelectList(_context.Group, "Id", "GroupName", aspirant.GroupId);
            return(View(aspirant));
        }
示例#7
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,ExamName,ExamDate")] Exams exams)
        {
            /* var elements = _context.Exams.ToArray();
             * foreach (var c in elements)
             * {
             *   if (exams.ExamName == c.ExamName)
             *   {
             *       ModelState.AddModelError("ExamName", "Coppy Error");
             *       return View(exams);
             *   }
             * } */

            if (id != exams.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(exams);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ExamsExists(exams.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(exams));
        }
        public async Task <IActionResult> Edit(int id, int groupID, [Bind("Id,Name,Surname,BirthDay")] Aspirant aspirant)
        {
            //   DateTime time_now = DateTime.Now;
            // DateTime d1 = new DateTime(2020, 1, 20, 6, 20, 40);
            //  DateTime d2 = aspirant.BirthDay.Value;
            //  if (DateTime.Compare(time_now, d2) <= 0) { ModelState.AddModelError("BirthDay", "BirthDay Error"); return View(aspirant); }

            aspirant.GroupId = groupID;
            if (id != aspirant.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(aspirant);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AspirantExists(aspirant.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index", "Aspirants", new { id = groupID, name = _context.Group.Where(c => c.Id == groupID).FirstOrDefault().GroupName }));
                //  return RedirectToAction(nameof(Index));
            }
            return(RedirectToAction("Index", "Aspirants", new { id = groupID, name = _context.Group.Where(c => c.Id == groupID).FirstOrDefault().GroupName }));
            // ViewData["GroupId"] = new SelectList(_context.Group, "Id", "GroupName", aspirant.GroupId);
            // return View(aspirant);
        }