public async Task <IActionResult> PutExam(int id, Exam exam)
        {
            if (id != exam.Id)
            {
                return(BadRequest());
            }

            _context.Entry(exam).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ExamExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutCurrency(string id, Currency currency)
        {
            if (id != currency.Id)
            {
                return(BadRequest());
            }

            _context.Entry(currency).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CurrencyExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> Edit(int id, ExamResult examResult)
        {
            if (id != examResult.Exam_Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(examResult);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ExamResultExists(examResult.Exam_Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(examResult));
        }
Esempio n. 4
0
        public async Task <IActionResult> Create([Bind("id,corse_title,credit_hours")] Subject subject)
        {
            if (ModelState.IsValid)
            {
                _context.Add(subject);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(subject));
        }
        public async Task <IActionResult> Create([Bind("TeacherId,TeacherName")] Teacher teacher)
        {
            if (ModelState.IsValid)
            {
                _context.Add(teacher);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(teacher));
        }
Esempio n. 6
0
        public async Task <IActionResult> Create([Bind("StudentId,StudentName,Roll_No")] Student student)
        {
            if (ModelState.IsValid)
            {
                _context.Add(student);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(student));
        }
Esempio n. 7
0
        public async Task <IActionResult> Create([Bind("AnswerSerial,Answer,Correct,QuestionNo")] Answers answers)
        {
            if (ModelState.IsValid)
            {
                _context.Add(answers);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["QuestionNo"] = new SelectList(_context.Questions, "QuestionNo", "QuestionNo", answers.QuestionNo);
            return(View(answers));
        }
Esempio n. 8
0
        public async Task <IActionResult> Create([Bind("QuestionId,QuestionName,Mark,ExamId")] Question question)
        {
            if (ModelState.IsValid)
            {
                _context.Add(question);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ExamId"] = new SelectList(_context.Exams, "ExamId", "ExamId", question.ExamId);
            return(View(question));
        }
Esempio n. 9
0
        public async Task <IActionResult> Create([Bind("TopicsCode,TopicsName,SubjectCode")] Topics topics)
        {
            if (ModelState.IsValid)
            {
                _context.Add(topics);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SubjectCode"] = new SelectList(_context.Subjects, "SubjectCode", "SubjectCode", topics.SubjectCode);
            return(View(topics));
        }
        public async Task <IActionResult> Create([Bind("AnswerId,AnswerName,IsRightAnswer,QuestionId")] Answer answer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(answer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["QuestionId"] = new SelectList(_context.Questions, "QuestionId", "QuestionId", answer.QuestionId);
            return(View(answer));
        }
        public async Task <IActionResult> Create([Bind("ExamId,ExamType,StartDate,EndDate,SubjectId")] Exam exam)
        {
            if (ModelState.IsValid)
            {
                _context.Add(exam);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SubjectId"] = new SelectList(_context.Subjects, "SubjectId", "SubjectId", exam.SubjectId);
            return(View(exam));
        }
Esempio n. 12
0
        public async Task <IActionResult> Create([Bind("SubjectCode,SubjectName,StudentId")] Subjects subjects)
        {
            if (ModelState.IsValid)
            {
                _context.Add(subjects);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["StudentId"] = new SelectList(_context.Students, "StudentId", "Class", subjects.StudentId);
            return(View(subjects));
        }
Esempio n. 13
0
        public async Task <IActionResult> Create([Bind("QuestionNo,Question,TopicsCode")] Questions questions)
        {
            if (ModelState.IsValid)
            {
                _context.Add(questions);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["TopicsCode"] = new SelectList(_context.Topics, "TopicsCode", "TopicsCode", questions.TopicsCode);
            return(View(questions));
        }
        public async Task <IActionResult> Create([Bind("ResultId,TotalMarks,ExamId,StudentId")] ExamResult examResult)
        {
            if (ModelState.IsValid)
            {
                _context.Add(examResult);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ExamId"]    = new SelectList(_context.Exams, "ExamId", "ExamId", examResult.ExamId);
            ViewData["StudentId"] = new SelectList(_context.Students, "StudentId", "StudentId", examResult.StudentId);
            return(View(examResult));
        }
Esempio n. 15
0
        public async Task <IActionResult> Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                User user = await db.Users.FirstOrDefaultAsync(u => u.Email == model.Email);

                if (user == null)
                {
                    // добавляем пользователя в бд
                    db.Users.Add(new User {
                        Email = model.Email, Password = model.Password, FirstName = model.FirstName, LastName = model.LastName
                    });
                    await db.SaveChangesAsync();

                    await Authenticate(model.Email); // аутентификация

                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    ModelState.AddModelError("", "Некорректные логин/пароль или учетная запись уже существует");
                }
            }
            return(View(model));
        }
Esempio n. 16
0
        public async Task <IActionResult> SaveProblemStatusType2(int problemType = 2, int questionNumber = 1)
        {
            var userId       = Guid.Parse(_identityService.GetUserIdentity());
            var userProScore = _examContext.UserProblemScores
                               .Where(x => x.ProblemType == problemType &&
                                      x.UserID == userId && x.QuestionNumber == questionNumber).FirstOrDefault();

            if (userProScore is null)
            {
                return(NotFound());
            }
            userProScore.IsSubmitOver = 1;
            _examContext.UserProblemScores.Update(userProScore);
            bool result = await _examContext.SaveChangesAsync() > 0;

            return(Ok(result));
        }
        public async Task <ActionResult> Create([Bind(Include = "Id,Name,ParentId")] Category category)
        {
            Category categoryFind = await db.Categories.FindAsync(category.Id);

            if (categoryFind != null)
            {
                ModelState.AddModelError("Id", "Category with the same Id already exists!");
                category.Id = 0;
            }
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.ParentId = new SelectList(db.Categories, "Id", "Name", category.ParentId);
            return(View("Edit", category));
        }
Esempio n. 18
0
        public async Task <ActionResult> MatchControl(MatchViewModel matchView)
        {
            if (ModelState.IsValid)
            {
                var match = _mapper.Map <Match>(matchView);
                await _context.Matches.AddAsync(match);

                await _context.SaveChangesAsync();
            }
            return(View("admin/Admin/Index"));
        }
Esempio n. 19
0
            public async Task <int> Handle(Command request, CancellationToken cancellationToken)
            {
                // Check for duplicate filename
                if (DoesFileAlreadyExist(request.Name))
                {
                    throw new FileExistException(request.Name, "File already exist.");
                }
                if (DoesFileSizeLimitExceeded(request.Content))
                {
                    throw new FileLimitException(request.Name, "File exceeds to 2MB.");
                }

                await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken);

                var file = _mapper.Map <Command, File>(request);

                _db.Files.Add(file);

                await _db.SaveChangesAsync(cancellationToken);

                return(file.Id);
            }
Esempio n. 20
0
        private async Task AddOrUpdateProcessAsync(int moduleType, int subType = 0, int number = 0)
        {
            var process = await _examContext.ExamProcesss.SingleOrDefaultAsync();

            if (process == null)
            {
                process            = new ExamProcess();
                process.SubType    = subType;
                process.ModuleType = moduleType;
                process.Number     = number;
                process.AddTime    = DateTime.Now;
                _examContext.Add(process);
            }
            else
            {
                process.ModuleType = moduleType;
                process.SubType    = subType;
                process.Number     = number;
                process.AddTime    = DateTime.Now;
                _examContext.Update(process);
            }
            await _examContext.SaveChangesAsync();
        }