コード例 #1
0
        public async Task <IActionResult> ReviewerRegister(RegisterReviewerViewModel model, string returnUrl = null)
        {
            ViewData["ReturnUrl"] = returnUrl;
            if (model.Language1Id != 0)
            {
                if (ModelState.IsValid)
                {
                    if (model.Language2Id == 0)
                    {
                        model.Language2Id = null;
                    }
                    if (model.Language3Id == 0)
                    {
                        model.Language3Id = null;
                    }
                    var cName = _context.Conference.First().Name;
                    var user  = new ApplicationUser {
                        UserName = model.Email, Email = model.Email, ConferenceName = cName, Name = model.Name, Surname = model.Surname
                    };
                    var result = await _userManager.CreateAsync(user, model.Password);

                    var userType = new Reviewer {
                        OrgName = model.OrgName, ScTitle = model.ScTitle, ApplicationUserId = user.Id, Language1Id = model.Language1Id, Language2Id = model.Language2Id, Language3Id = model.Language3Id
                    };
                    _context.Add(userType);
                    await _context.SaveChangesAsync();

                    if (result.Succeeded)
                    {
                        _logger.LogInformation("User created a new account with password.");

                        var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                        var callbackUrl = Url.EmailConfirmationLink(user.Id, code, Request.Scheme);
                        await _emailSender.SendEmailConfirmationAsync(model.Email, callbackUrl);

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

                        _logger.LogInformation("User created a new account with password.");
                        return(RedirectToLocal(returnUrl));
                    }
                    AddErrors(result);
                }
            }

            // If we got this far, something failed, redisplay form
            List <Language> languageList = new List <Language>();

            languageList = (from language in _context.Language select language).ToList();
            var nullLanguage = new Language();

            languageList.Insert(0, nullLanguage);
            ViewBag.ListofLanguages = languageList;
            return(View(model));
        }
コード例 #2
0
        public async Task <IActionResult> Create([Bind("ReviewId,Problems,WhyProblems,Solution,Achievements,NotMentioned,Grade,GeneralComments,PaperId")] Review review)
        {
            var currentUser = await _userManager.GetUserAsync(HttpContext.User);

            currentUser = _context.ApplicationUser
                          .Include(ap => ap.Users)
                          .FirstOrDefault(ap => ap.Id == currentUser.Id);

            var reviewerId = _context.Paper.Find(review.PaperId).ReviewerId;

            foreach (var userType in currentUser.Users)
            {
                if (userType.UserTypeId == reviewerId)
                {
                    if (ModelState.IsValid)
                    {
                        _context.Paper.Find(review.PaperId).Status = Paper.ProcessStatus.Reviewed;
                        review.Date = DateTime.Now;
                        _context.Add(review);
                        await _context.SaveChangesAsync();

                        return(RedirectToAction(nameof(Index)));
                    }
                    return(View(review));
                }
            }
            return(View("AccessDenied"));
        }
コード例 #3
0
        public async Task <IActionResult> Index(string sortOrder, string searchString, string currentFilter, int?page)
        {
            // Sorting properties
            ViewData["TitleENGSortParam"] = String.IsNullOrEmpty(sortOrder) ? "TitleENGDesc" : "";
            ViewData["AuthorSortParam"]   = sortOrder == "AuthorAsc" ? "AuthorDesc" : "AuthorAsc";
            ViewData["AuthorsSortParam"]  = sortOrder == "AuthorsAsc" ? "AuthorsDesc" : "AuthorsAsc";
            ViewData["ReviewerSortParam"] = sortOrder == "ReviewerAsc" ? "ReviewerDesc" : "ReviewerAsc";
            ViewData["StatusSortParam"]   = sortOrder == "StatusAsc" ? "StatusDesc" : "StatusAsc";
            // Pagination propertie
            ViewData["CurrentSort"] = sortOrder;
            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }
            int pageSize = 10;

            // Searching propertie
            ViewData["CurrentFilter"] = searchString;

            var currentUserId = _userManager.GetUserId(HttpContext.User);

            var papers = _context.Paper
                         .Include(p => p.Author.ApplicationUser)
                         .Include(p => p.PaperKeywords)
                         .Include(p => p.Reviewer.ApplicationUser)
                         .Include(p => p.Payment);


            var currentUser = _context.ApplicationUser
                              .Include(ap => ap.Users)
                              .FirstOrDefault(ap => ap.Id == currentUserId);

            ViewData["UserString"] = currentUser.Users.FirstOrDefault().GetType().ToString();

            foreach (var userType in currentUser.Users)
            {
                switch (userType.GetType().ToString())
                {
                case "ConFutureNce.Models.Author":
                {
                    var authorId = userType.UserTypeId;

                    IEnumerable <Paper> model = papers
                                                .Where(p => p.AuthorId == authorId)
                                                .OrderBy(p => p.TitleENG);

                    // Delete unpaid papers
                    var toDelete = model.Where(p => p.Payment == null);
                    _context.Paper.RemoveRange(toDelete);
                    await _context.SaveChangesAsync();

                    model = SearchPapers(model, searchString);
                    model = SortPapers(model, sortOrder);
                    model = PaginatedList <Paper> .Create(model, page ?? 1, pageSize);


                    return(View("Author", (PaginatedList <Paper>)model));
                }

                case "ConFutureNce.Models.Reviewer":
                {
                    var reviewerId            = userType.UserTypeId;
                    IEnumerable <Paper> model = papers
                                                .Where(p => p.ReviewerId == reviewerId)
                                                .OrderBy(p => p.TitleENG);

                    model = SearchPapers(model, searchString);
                    model = SortPapers(model, sortOrder);
                    model = PaginatedList <Paper> .Create(model, page ?? 1, pageSize);

                    return(View("Reviewer", (PaginatedList <Paper>)model));
                }

                case "ConFutureNce.Models.ProgrammeCommitteeMember":
                {
                    IEnumerable <Paper> model = papers
                                                .OrderBy(p => p.TitleENG);

                    model = SearchPapers(model, searchString);
                    model = SortPapers(model, sortOrder);
                    model = PaginatedList <Paper> .Create(model, page ?? 1, pageSize);

                    return(View("ProgrammeCommitteeMember", (PaginatedList <Paper>)model));
                }
                }
            }

            return(RedirectToAction("AccessDenied", "Account", null));
        }