コード例 #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> Create([Bind("PaperId,TitleENG,TitleORG,Authors,Abstract,OrgName,LanguageId,PaperKeywords")] ViewModels.PaperPaperKeyworsViewModel paperPaperKeyword, IFormFile file)
        {
            var userId = _userManager.GetUserId(HttpContext.User);

            var user = _context.ApplicationUser
                       .Include(ap => ap.Users)
                       .FirstOrDefault(ap => ap.Id == userId);

            foreach (var userType in user.Users)
            {
                if (userType.GetType().ToString() == "ConFutureNce.Models.Author")
                {
                    if (ModelState.IsValid & file != null)
                    {
                        var paper = new Paper
                        {
                            Abstract   = paperPaperKeyword.Abstract,
                            TitleENG   = paperPaperKeyword.TitleENG,
                            TitleORG   = paperPaperKeyword.TitleORG,
                            Authors    = paperPaperKeyword.Authors,
                            OrgName    = paperPaperKeyword.OrgName,
                            LanguageId = paperPaperKeyword.LanguageId
                        };

                        var userTypeId = user.Users.First().UserTypeId;
                        paper.AuthorId = userTypeId;
                        if (paperPaperKeyword.PaperKeywords != null)
                        {
                            var paperKeywordsTableWithRepeats = paperPaperKeyword.PaperKeywords.Split(",");
                            for (int i = 0; i < paperKeywordsTableWithRepeats.Length; i++)
                            {
                                paperKeywordsTableWithRepeats[i] = paperKeywordsTableWithRepeats[i].Trim();
                            }
                            paperKeywordsTableWithRepeats = paperKeywordsTableWithRepeats.Where(x => !string.IsNullOrEmpty(x)).ToArray();
                            var paperKeywordsTable  = paperKeywordsTableWithRepeats.Distinct().ToArray();
                            List <PaperKeyword> ppk = new List <PaperKeyword>();

                            foreach (string keyword in paperKeywordsTable)
                            {
                                var paperKeywords = new PaperKeyword
                                {
                                    KeyWord = keyword,
                                    Paper   = paper
                                };
                                ppk.Add(paperKeywords);
                            }
                            paper.PaperKeywords = ppk;
                        }
                        using (var memoryStream = new MemoryStream())
                        {
                            await file.CopyToAsync(memoryStream);

                            paper.PaperFile = memoryStream.ToArray();
                        }
                        paper.SubmissionDate = DateTime.Now;
                        paper.Status         = 0;
                        _context.Add(paper);
                        await _context.SaveChangesAsync();

                        return(RedirectToAction("Index", "Payments", new PaymentViewModel
                        {
                            UserName = user.Fullname,
                            BillingAddress = user.Address,
                            PaperId = paper.PaperId
                        }));
                    }
                    ICollection <Language> languageList = new List <Language>();
                    languageList            = (from language in _context.Language select language).ToList();
                    ViewBag.ListofLanguages = languageList;
                    return(View(paperPaperKeyword));
                }
            }

            return(RedirectToAction("Index"));
        }