我创建了一个Crud对象来跟踪员工的假期,在我的HTTP Post EDIT方法中,当经理编辑将{{1}更改为布尔状态的请求时,我想使用一个电子邮件操作(已经起作用) }到pending
。
这是我尝试过的,但是我的C#尚未达到标准。
approved
当管理员将请求的状态修改为true时,如何发送电子邮件(调用SendMailToManager()操作)?
答案 0 :(得分:0)
让它为那些偶然发现此问题的人提供帮助。仅仅是
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit([Bind(Include = "RequestID,EmployeeID,StartDate,FinishDate,HoursTaken,Comments,YearCreated,MonthCreated,DayCreated,YearOfHoliday,Approved,SubmittedBy,ApprovedBy")] HolidayRequestForm holidayRequestForm)
{
if (ModelState.IsValid)
{
if (Session["Name"] == null)
{
TempData["msg"] = "Your Session Expired - Please Login";
return RedirectToAction("Login", "Account");
}
string name = Session["Name"].ToString();
var approvedby = db.Employees.Where(s => s.Email.Equals(name)).Select(s => s.Email).FirstOrDefault();
holidayRequestForm.ApprovedBy = approvedby;
db.Entry(holidayRequestForm).State = EntityState.Modified;
db.SaveChanges();
if ( holidayRequestForm.Approved == true){
SendMailToAreaManager();
SendMailToManager();
SendMailToAdmin();
}
答案 1 :(得分:0)
变量从不大写!
if (ApprovedStatus = true){
SendMailToManager();
}
TO
if (approvedStatus == true){
SendMailToManager();
}