コード例 #1
0
        public IActionResult Email(int id)
        {
            if (id != 0)
            {
                CitizenReport citizenReport = _examDBContect.DbCitizenReport.FirstOrDefault(p => p.Id == id);

                var SmtpServer    = _configuration["EmailConfiguration:SmtpServer"];
                var SmtpPort      = Convert.ToInt32(_configuration["EmailConfiguration:SmtpPort"]);
                var SmtpUsername  = _configuration["EmailConfiguration:SmtpUsername"];
                var SmtpPassword  = _configuration["EmailConfiguration:SmtpPassword"];
                var testSumResult = citizenReport.Result_Test1 + citizenReport.Result_Test2;
                var Time1         = (citizenReport.Test1DataTime).ToString("dd/MM/yyyy HH:mm");
                var Time2         = (citizenReport.Test2DataTime).ToString("dd/MM/yyyy HH:mm");
                var subject       = "Հարգելի " + citizenReport.LastName + " " + citizenReport.FirstName;

                var text = " Դուք  , մասնակցել էք Ընտրությունների անցկացման մասնագիտական դասընթացներ ստուգարքին համակարգչային եղանակով և ստացել եք " + testSumResult + " միավոր: "
                           + " Խնդիրը հանձնել եք " + Time1 + "-ին, և ստացել եք " + citizenReport.Result_Test1 + " միավոր "
                           + " Հարցաշարը հանձնել եք " + Time2 + "-ին, և ստացել եք " + citizenReport.Result_Test2 + " միավոր: "
                           + " Դասընթացների մասին լրացուցիչ ինֆորմացիա կարող եք ստանալ այցելելով https://www.elections.am կայք  Մասնագիտական դասընտացներ բաժին:  ";


                MailSender.Sender(SmtpServer, SmtpPort, SmtpUsername, SmtpPassword, citizenReport.Email, subject, text);

                citizenReport.Notification     = true;
                citizenReport.NotificationData = DateTime.Now;
                _examDBContect.Update(citizenReport);
                _examDBContect.SaveChanges();
            }

            List <CitizenReport> citizenReportList = _examDBContect.DbCitizenReport.ToList();

            return(View(citizenReportList));
        }
コード例 #2
0
        public IActionResult DeleteQuestion(int QId)
        {
            var question = _examDBContect.DbQuestion.FirstOrDefault(p => p.QId == QId);

            _examDBContect.DbQuestion.Remove(question);
            _examDBContect.SaveChanges();

            return(RedirectToAction("ListQuestions"));
        }
コード例 #3
0
        public async Task <IActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                // Copy data from RegisterViewModel to IdentityUser
                var user = new CitizenUser
                {
                    UserName    = model.Email,
                    Email       = model.Email,
                    FirstName   = model.FirstName,
                    LastName    = model.LastName,
                    SecondName  = model.SecondName,
                    Passport    = model.Passport,
                    PhoneNumber = model.PhoneNumber
                };

                // Store user data in AspNetUsers database table
                var result = await _userManager.CreateAsync(user, model.Password);

                // If user is successfully created, sign-in the user using
                // SignInManager and redirect to index action of HomeController
                if (result.Succeeded)
                {
                    CitizenReport citizenReport = new CitizenReport()
                    {
                        FirstName        = user.FirstName,
                        LastName         = user.LastName,
                        SecondName       = user.SecondName,
                        PhoneNumber      = user.PhoneNumber,
                        Email            = user.Email,
                        Test1DataTime    = DateTime.MinValue,
                        Test2DataTime    = DateTime.MinValue,
                        Test1Check       = false,
                        Test2Check       = false,
                        Result_Test1     = 0,
                        NumberTicket     = 0,
                        Passport         = user.Passport,
                        Notification     = false,
                        NotificationData = DateTime.MinValue
                    };

                    _examDBContect.DbCitizenReport.Update(citizenReport);
                    _examDBContect.SaveChanges();

                    await _signInManager.SignInAsync(user, isPersistent : false);

                    return(RedirectToAction("index", "home"));
                }

                // If there are any errors, add them to the ModelState object
                // which will be displayed by the validation summary tag helper
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
            }

            return(View(model));
        }
コード例 #4
0
        public IActionResult Test(CitizenTestResults citizenTestResults, int testTicket)
        {
            //  if (ModelState.IsValid)
            //   {
            citizenTestResults.NumberTicket = testTicket;
            _examDBContect.Add(citizenTestResults);
            _examDBContect.SaveChanges();

            //   }

            EmptyTextViewModel emptyTextViewModel = _examDBContect.DbEmptyTextViewModel
                                                    .FirstOrDefault(p => p.Id == testTicket);
            CitizenTestViewModel citizenTestViewModel = _testChecked.TestResult(citizenTestResults, emptyTextViewModel);

            citizenTestResults.Result = citizenTestViewModel.Result;

            //ViewBags Start

            ViewBag.NumberTicket = emptyTextViewModel.Id;
            ViewBag.Region       = emptyTextViewModel.Region;
            ViewBag.Community    = emptyTextViewModel.Community;
            ViewBag.CEC          = emptyTextViewModel.CEC;
            ViewBag.TEC          = emptyTextViewModel.TEC;
            ViewBag.Participants = emptyTextViewModel.Participants;
            ViewBag.AllAdditionallyDuringElDay = emptyTextViewModel.AllAdditionallyDuringElDay;
            ViewBag.AllMobileVoters            = emptyTextViewModel.AllMobileVoters;
            ViewBag.PartMobileVoters           = emptyTextViewModel.PartMobileVoters;
            ViewBag.VadTickets             = emptyTextViewModel.VadTickets;
            ViewBag.NumerableTickets       = emptyTextViewModel.NumerableTickets;
            ViewBag.UnusedNumerableTickets = emptyTextViewModel.UnusedNumerableTickets;
            ViewBag.UnusedGlueTickets      = emptyTextViewModel.UnusedGlueTickets;
            ViewBag.InvalidTickets         = emptyTextViewModel.InvalidTickets;
            ViewBag.ForA                = emptyTextViewModel.ForA;
            ViewBag.ForB                = emptyTextViewModel.ForB;
            ViewBag.ForC                = emptyTextViewModel.ForC;
            ViewBag.ForAx               = emptyTextViewModel.ForAx;
            ViewBag.ForAy               = emptyTextViewModel.ForAy;
            ViewBag.ForBm               = emptyTextViewModel.ForBm;
            ViewBag.ForBn               = emptyTextViewModel.ForBn;
            ViewBag.ForCk               = emptyTextViewModel.ForCk;
            ViewBag.ForCl               = emptyTextViewModel.ForCl;
            ViewBag.ListAll             = emptyTextViewModel.ListAll;
            ViewBag.TecGlueTickets      = emptyTextViewModel.TecGlueTickets;
            ViewBag.TecNumerableTickets = emptyTextViewModel.TecNumerableTickets;

            //ViewBags end

            CitizenUser citizenUser = new CitizenUser();

            if (User.Identity.IsAuthenticated)
            {
                var userName = User.Identity.Name;
                citizenUser = _userManager.Users.FirstOrDefault(p => p.Email == userName);

                ViewBag.UserFullName = citizenUser.FirstName + " " +
                                       citizenUser.SecondName + " " +
                                       citizenUser.LastName;
            }

            CitizenReport citizenReport = _examDBContect.DbCitizenReport
                                          .FirstOrDefault(p => p.Passport == citizenUser.Passport);

            citizenReport.Test1DataTime = DateTime.Now;
            citizenReport.Test1Check    = true;
            citizenReport.Result_Test1  = citizenTestViewModel.Result;
            citizenReport.NumberTicket  = citizenTestViewModel.NumberTicket;



            _examDBContect.Update(citizenReport);
            _examDBContect.SaveChanges();

            TempQuestions tempQuestions = new TempQuestions();

            tempQuestions         = _examDBContect.DbTempQuestions.FirstOrDefault(p => p.Passport == citizenUser.Passport);
            tempQuestions.TestEnd = true;
            _examDBContect.DbTempQuestions.Update(tempQuestions);
            _examDBContect.SaveChanges();

            return(View(citizenTestViewModel));
        }