public async Task <IActionResult> CreateCompetition(Competition competition)
        {
            if (ModelState.IsValid)
            {
                EmailCofirm emailCofirm = new EmailCofirm();
                if (competition.StartDate < competition.EndDate)
                {
                    var user = _userManager.Users.SingleOrDefault(u => u.Id == competition.UserID);
                    competition.CreatedAt = DateTime.Now;
                    competition.UpdatedAt = DateTime.Now;
                    competition.Available = true;
                    competition.AwardDate = competition.EndDate.AddDays(2);
                    competition.StartDate = competition.StartDate.Date;
                    CheckStatus(competition);
                    _context.Add(competition);

                    emailCofirm.SendMail(user.Email, user.UserName, $"You are selected as a judge for a competition < a href = '{HtmlEncoder.Default.Encode("https://localhost:44312/Staffs/DetailsCompetition/" + competition.ID)}' > clicking here </ a >.");

                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(CompetitionList)));
                }
                TempData["Error"] = "Invalid start date & end date!";
            }

            var staffList = await _userManager.GetUsersInRoleAsync("staff");

            ViewData["UserID"] = new SelectList(staffList, "Id", "FullName", competition.UserID);
            return(View(competition));
        }
        public async Task <IActionResult> Attend([Bind("PostName,Decription")] Post post, IFormFile Image, int id)
        {
            EmailCofirm emailCofirm = new EmailCofirm();

            if (ModelState.IsValid)
            {
                var user = await GetCurrentUserAsync();

                using (var ms = new MemoryStream())
                {
                    Image.CopyTo(ms);
                    post.Image = ms.ToArray();
                }
                post.CreatedAt = DateTime.Now;
                post.UpdatedAt = DateTime.Now;
                post.UserID    = user.Id;
                post.Available = true;
                _context.Add(post);
                _context.CompetitionPost.Add(new CompetitionPost {
                    CompetitionID = id, PostID = post.ID, UserID = user.Id, SubmitDate = DateTime.Now, Available = true
                });

                var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                var callbackUrl = Url.Page(
                    "/Account/ConfirmEmail",
                    pageHandler: null,
                    values: new { userId = user.Id, code = code },
                    protocol: Request.Scheme);


                emailCofirm.SendMail(user.Email, user.UserName, $"You posted an entry < a href = '{HtmlEncoder.Default.Encode(callbackUrl)}' > clicking here </ a >.");
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(MyAccount)));
            }
            return(View(post));
        }