public bool SendExpenseEmail(int id)
        {
            var expense = expenseManager.Get(id);

            if (expense != null)
            {
                try
                {
                    var user = employeeManager.Find(a => a.Designation == "FinanceManager");

                    ExpenseEmail expenseEmail = new ExpenseEmail();
                    expenseEmail.ToEmail = user.Email;
                    expenseEmail.Subject = "Trivago Travel Expense Submitted";
                    expenseEmail.Body    = $"An expense has been submitted with title: '{expense.Title}'";

                    expenseEmailService.SendExpenseEmail(expenseEmail);

                    return(true);
                }
                catch (Exception ex)
                {
                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        public void SendExpenseEmail(ExpenseEmail model)
        {
            string      template = "Templates.ExpenseSubmit";
            RazorParser renderer = new RazorParser(typeof(IExpenseEmailService).Assembly);
            var         body     = renderer.UsingTemplateFromEmbedded(template, model);

            SendEmail(new List <string>()
            {
                model.ToEmail
            }, model.Subject, body, typeof(IExpenseEmailService));
        }