コード例 #1
0
        public async Task <IActionResult> ActiveAccount(int?id)
        {
            var buyerAccount = await _context.Account.FindAsync(id);



            if (buyerAccount.IsActive == 1)
            {
                buyerAccount.IsActive = 0;
                _context.Account.Attach(buyerAccount).Property(x => x.IsActive).IsModified = true;
                await MailUtils.SendMailGoogleSmtp("*****@*****.**", buyerAccount.Email, "Wasted Food thông báo", "Tài khoản của bạn đã bị khóa, vui lòng liên hệ lại với admin thông qua địa chỉ email này: [email protected] để được hỗ trợ ",
                                                   "*****@*****.**", "fall2020@WastedFoodSystem");

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Account)));
            }
            else if (buyerAccount.IsActive == 0)
            {
                buyerAccount.IsActive = 1;
                _context.Account.Attach(buyerAccount).Property(x => x.IsActive).IsModified = true;
                await MailUtils.SendMailGoogleSmtp("*****@*****.**", buyerAccount.Email, "Wasted Food thông báo", "Tài khoản của bạn đã được mở khóa, vui lòng liên hệ lại với admin thông qua địa chỉ email này: [email protected] để được hỗ trợ ",
                                                   "*****@*****.**", "fall2020@WastedFoodSystem");

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Account)));
            }
            return(RedirectToAction(nameof(Index)));
        }
コード例 #2
0
        public async Task <IActionResult> ActiveAccount(int?id)
        {
            var sellerAccount = await _context.Account.FindAsync(id);


            if (sellerAccount.IsActive == 2)
            {
                sellerAccount.IsActive = 1;
                _context.Account.Attach(sellerAccount).Property(x => x.IsActive).IsModified = true;
                await MailUtils.SendMailGoogleSmtp("*****@*****.**", sellerAccount.Email, "Chào mừng bạn đến với Wasted Food", "Tài khoản của bạn đã được thông qua xét duyệt và trở thành thành viên của chúng tôi dưới đây là thông tin tài khoản của bạn \n " + "Tên tài khoản : " + sellerAccount.Username + "\n",
                                                   "*****@*****.**", "fall2020@WastedFoodSystem");

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(WaitForActive)));
            }
            else if (sellerAccount.IsActive == 1)
            {
                sellerAccount.IsActive = 0;
                _context.Account.Attach(sellerAccount).Property(x => x.IsActive).IsModified = true;
                await MailUtils.SendMailGoogleSmtp("*****@*****.**", sellerAccount.Email, "Wasted Food thông báo", "Tài khoản của bạn đã bị khóa, vui lòng liên hệ lại với admin thông qua địa chỉ email này: [email protected] để được hỗ trợ ",
                                                   "*****@*****.**", "fall2020@WastedFoodSystem");

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Account)));
            }
            else if (sellerAccount.IsActive == 0)
            {
                sellerAccount.IsActive = 1;
                _context.Account.Attach(sellerAccount).Property(x => x.IsActive).IsModified = true;
                await MailUtils.SendMailGoogleSmtp("*****@*****.**", sellerAccount.Email, "Wasted Food thông báo", "Tài khoản của bạn đã được mở khóa, vui lòng liên hệ lại với admin thông qua địa chỉ email này: [email protected] để được hỗ trợ ",
                                                   "*****@*****.**", "fall2020@WastedFoodSystem");

                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Account)));
            }
            return(RedirectToAction(nameof(Index)));
        }