コード例 #1
0
        public async Task <IActionResult> EmailVerify(string id)
        {
            if (id != null)
            {
                ApplicationUser user = await _userManager.FindByIdAsync(id);



                if (user != null)
                {
                    user.EmailConfirmed           = true;
                    TempData["Email Təsdiqləndi"] = true;



                    await _context.SaveChangesAsync();
                }
            }
            TempData["Verify"] = true;
            return(RedirectToAction("Login", "Account"));
        }
コード例 #2
0
        public async Task <IActionResult> ConfirmAnnouncement(int?id)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToAction("AdminLogin", "Dashboard"));
            }
            Announcement selectedAds = _context.Announcements.FirstOrDefault(a => a.Id == id);

            selectedAds.IsConfirmed = true;

            SmtpClient client = new SmtpClient("smtp.gmail.com", 587);

            client.UseDefaultCredentials = false;
            client.EnableSsl             = true;
            client.Credentials           = new NetworkCredential(_configuration["ConnectionsStrings:SmtpClientCredentialEmail"], _configuration["ConnectionsStrings:SmtpClientCredentialPassword"]);
            MailMessage message = new MailMessage("*****@*****.**", selectedAds.User.Email);

            message.IsBodyHtml = true;
            message.Subject    = "Elan Təsdiqi";
            message.Body       = $"<h1>Sizin Elanınız Təsdiqləndi.Təşəkkürlər</h1>";
            await client.SendMailAsync(message);

            await _context.SaveChangesAsync();


            return(RedirectToAction("DontConfirmedAnnouncements", "Dashboard"));
        }
コード例 #3
0
        public async Task <IActionResult> DeleteAdsImage(int?ImageId)
        {
            AnsImages deletingImage = _context.AnsImages.FirstOrDefault(i => i.Id == ImageId);

            if (deletingImage.Id != ImageId)
            {
                return(RedirectToAction("Error", "Home"));
            }


            _context.AnsImages.Remove(deletingImage);
            await _context.SaveChangesAsync();

            return(RedirectToAction("EditAds", "Account"));
        }