Exemple #1
0
        public async Task <IActionResult> Create([Bind("Id,Name,Surname,BirthDay,GroupId")] Aspirant aspirant)
        {
            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));
                }

                var elements = _context.Aspirant.ToArray();
                foreach (var c in elements)
                {
                    //if ((aspirant.Name == c.Name) && (aspirant.Surname == c.Surname) && (aspirant.BirthDay == c.BirthDay) )
                    if ((aspirant.Name == c.Name) && (aspirant.Surname == c.Surname))
                    {
                        ModelState.AddModelError("Name", "Coppy Error");
                        ViewData["GroupId"] = new SelectList(_context.Group, "Id", "GroupName", aspirant.GroupId);
                        return(View(aspirant));
                    }
                }
                _context.Add(aspirant);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GroupId"] = new SelectList(_context.Group, "Id", "GroupName", aspirant.GroupId);
            return(View(aspirant));
        }
Exemple #2
0
        public async Task <IActionResult> Create(int cathedraID, [Bind("Id,GroupName,TypeOfStudying")] Group @group)
        {
            @group.CathedraId = cathedraID;
            if (ModelState.IsValid)
            {
                _context.Add(@group);
                await _context.SaveChangesAsync();

                //  return RedirectToAction(nameof(Index));
                return(RedirectToAction("Index", "Groups1", new { id = cathedraID, name = _context.Cathedras.Where(c => c.Id == cathedraID).FirstOrDefault().CathedraName }));
            }
            //ViewData["CathedraId"] = new SelectList(_context.Cathedras, "Id", "Id", @group.CathedraId);
            //  return View(@group);
            return(RedirectToAction("Index", "Groups1", new { id = cathedraID, name = _context.Cathedras.Where(c => c.Id == cathedraID).FirstOrDefault().CathedraName }));
        }
Exemple #3
0
        public async Task <IActionResult> Create(int sessionId, [Bind("Id,ExamId")] Schedule schedule)
        {
            schedule.SessionId = sessionId;
            //  if (ModelState.IsValid)
            // {
            _context.Add(schedule);
            await _context.SaveChangesAsync();

            // return RedirectToAction(nameof(Index));
            return(RedirectToAction("Index", "Schedules1", new { id = sessionId }));

            //   }
            //   ViewData["ExamId"] = new SelectList(_context.Exams, "Id", "ExamName", schedule.ExamId);
            //ViewData["SessionId"] = new SelectList(_context.Sessions, "Id", "Id", schedule.SessionId);
            return(RedirectToAction("Index", "Schedules1", new { id = sessionId }));
        }
Exemple #4
0
        public async Task <IActionResult> Create([Bind("Id,GroupName,TypeOfStudying,CathedraId")] Group @group)
        {
            if (ModelState.IsValid)
            {
                //ModelState.AddModelError("GroupName", "Error");
                //return View(@group);
                _context.Add(@group);
                //@group.GroupName

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CathedraId"] = new SelectList(_context.Cathedras, "Id", "CathedraName", @group.CathedraId);
            return(View(@group));
        }
        public async Task <IActionResult> Create(int sessionId, int groupID, string groupName, [Bind("Id,ExamId")] Schedule schedule)
        {
            //ViewBag.GroupID = groupID;
            schedule.SessionId = sessionId;
            //  var examByGroup = _context.Schedule.Where(b => b.SessionId == sessionID).Include(b => b.Exam);
            if (ModelState.IsValid)
            {
                _context.Add(schedule);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", "Schedules", new { id = groupID, name = groupName, sessionID = sessionId }));
                //  return View(await examByGroup.ToListAsync());
            }
            ViewData["ExamId"] = new SelectList(_context.Exams, "Id", "Id", schedule.ExamId);
            // ViewData["SessionId"] = new SelectList(_context.Sessions, "Id", "Id", schedule.SessionId);
            //return View(schedule);
            //return View(await examByGroup.ToListAsync());
            return(RedirectToAction("Index", "Schedules", new { id = groupID, name = groupName, sessionID = sessionId }));
        }
        public async Task <IActionResult> Create(int groupID, [Bind("Id,Name,Surname,BirthDay")] Aspirant aspirant)
        {
            //  if (ModelState.ContainsKey("{Name}"))
            //    ModelState["{Name}"].Errors.Clear();

            //  DateTime time_now = DateTime.Now;
            //  DateTime d2 = aspirant.BirthDay.Value;
            //  if (DateTime.Compare(time_now, d2) <= 0) { ModelState.AddModelError("BirthDay", "BirthDay Error"); return View(aspirant); }



            aspirant.GroupId = groupID;
            if (ModelState.IsValid)
            {
                var elements = _context.Aspirant.ToArray();
                foreach (var c in elements)
                {
                    //if ((aspirant.Name == c.Name) && (aspirant.Surname == c.Surname) && (aspirant.BirthDay == c.BirthDay) )
                    if ((aspirant.Name == c.Name) && (aspirant.Surname == c.Surname))
                    {
                        ViewData["GroupId"] = groupID;
                        ModelState.AddModelError("Name", "Coppy Error");
                        return(View(aspirant));
                    }
                }


                //  if (_context.Aspirant.Where(c => (c.Name == aspirant.Name)&&(c.Surname == aspirant.Surname)).Count() != 0 )
                // {
                //     ModelState.AddModelError("Name", "Coppy Error");
                //     return View(aspirant);
                //  }
                _context.Add(aspirant);
                await _context.SaveChangesAsync();

                // 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 RedirectToAction("Index", "Aspirants", new { id = groupID, name = _context.Group.Where(c => c.Id == groupID).FirstOrDefault().GroupName });
            return(View(aspirant));
        }
Exemple #7
0
        public async Task <IActionResult> Create([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 (ModelState.IsValid)
            {
                _context.Add(exams);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(exams));
        }
        public async Task <IActionResult> Create(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 (ModelState.IsValid)
            {
                _context.Add(cathedras);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", "Cathedras", new { id = facultyID, name = _context.Faculties.Where(c => c.Id == facultyID).FirstOrDefault().FacultyName }));
            }
            return(RedirectToAction("Index", "Cathedras", new { id = facultyID, name = _context.Faculties.Where(c => c.Id == facultyID).FirstOrDefault() }));
        }
        public async Task <IActionResult> Create([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 (ModelState.IsValid)
            {
                _context.Add(sessions);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GroupId"] = new SelectList(_context.Group, "Id", "GroupName", sessions.GroupId);
            return(View(sessions));
        }