i would like to add some more functionalities to my method, such as an email to be sent once the user has successfully edited the data. i debugged the code but no errors are generated so i do not know where i am going wrong.
[HttpPost]
public ActionResult Edit(EditPTG eptg)
{
try
{
using (ManageGrade gradeLogic = new ManageGrade(ref uow))
{
foreach (var ptg in eptg.ptgForGrade)
{
ptg.Overwritten = true;
ptg.Active = true;
productToGradeLogic.Update(ptg);
}
//Need to investigate why we need to recalculate grade at this point of time - Sri to Mark??
//eptg.grade = GradeHelpers.RecalculateGradeStringFromProductAssignment(eptg.ptgForGrade, eptg.grade);
SmtpClient smtpClient = new SmtpClient("www.Hotmail.com", 25);
// smtpClient.Credentials = new System.Net.NetworkCredential("username", "password");
smtpClient.UseDefaultCredentials = true;
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.EnableSsl = true;
MailMessage mail = new MailMessage();
mail.From = new MailAddress("www.example.com");
mail.To.Add(new MailAddress("[email protected]"));
mail.CC.Add(new MailAddress("[email protected]"));
smtpClient.Send(mail);
gradeLogic.Update(eptg.grade);
TempData["Success"] = "Edit Successful";
return RedirectToAction("Index");
}
}
catch
{
TempData["Failure"] = "Edit Failed, Please Review Your Selections and Try Again.";
return View(eptg);
}
}