public ActionResult SendExpense(int id)
        {
            string username = User.Identity.GetUserName();

            HistoryRepository.AddExpenseHistory(id, username);
            repository.UpdateStatus(id);
            return(RedirectToAction("ExpenseList", "Manager"));
        }
示例#2
0
        public async Task <ActionResult> PayExpense(int id)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("PendingExpenses"));
            }
            var body    = "Expense request was sent";
            var message = new MailMessage();

            message.To.Add(new MailAddress("*****@*****.**"));      // replace with valid value
            message.From       = new MailAddress("*****@*****.**"); // replace with valid value
            message.Subject    = "Expense";
            message.Body       = string.Format(body);
            message.IsBodyHtml = true;

            using (var smtp = new SmtpClient())
            {
                var credential = new NetworkCredential
                {
                    UserName = "******", // replace with valid value
                    Password = "******"               // replace with valid value
                };
                smtp.Credentials = credential;
                smtp.Host        = "mail.veripark.com";
                smtp.Port        = 25;
                smtp.EnableSsl   = false;
                await smtp.SendMailAsync(message);

                var userId = User.Identity.GetUserName();

                HistoryRepository.AddExpenseHistory(id, userId);

                repository.UpdateStatusPayment(id);

                return(RedirectToAction("Index", "Home"));

                ;
            }
        }