public ActionResult NotifyCustomer(int id, int notificationType, string comments) { if (Utilities.IsUserLogged()) { List <HttpPostedFileBase> attachments = new List <HttpPostedFileBase>(); try { HttpFileCollectionBase files = Request.Files; for (int i = 0; i < files.Count; i++) { //save the attachments attachments.Add(files[i]); } } catch (Exception ex) { return(Json("Error uploading file")); } //get the email list for the specific project List <Project_Email> list = db.Project_Email.Where(x => x.project_id == id).ToList(); Customer_Project c = db.Customer_Project.Find(id); EmailHandler email = new EmailHandler(); Boolean result = email.NotifyCustomer(list, notificationType, comments, attachments, c); if (result == true) { if (notificationType == 1) { c.initialNotification = true; } else if (notificationType == 3) { c.finalNotification = true; } db.SaveChanges(); // Returns message that successfully uploaded return(Json("The notification was sent correctly.")); } else { // Returns message that successfully uploaded return(Json("Unable to send notification, please try again.")); } } else { return(Json("-1")); } }