public ActionResult Assign(HttpPostedFileBase file, AssignViewModel model) { if (file == null) { ModelState.AddModelError(string.Empty, "Mohon upload file pendukung."); PrepareAssignSelectList(); return(View(model)); } Report report = new Report(); report.Id = model.Id; report.PPKId = model.PPKId; report.StaffComment = model.StaffComment; _reportLogic.AssignReport(report); if (file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); var filePath = model.Id + "_" + fileName; var path = Path.Combine(Server.MapPath("~/Content/UploadStaff"), filePath); file.SaveAs(path); StaffFile staffFile = new StaffFile(); staffFile.FileName = fileName; staffFile.ReportId = model.Id; _staffFileLogic.Create(staffFile); } try { var ppk = _ppkLogic.GetById(model.PPKId); if (ppk != null) { if (ppk.PIC != null) { var msg = new MailMessage(); msg.To.Add(new MailAddress(ppk.PIC.Email)); msg.Subject = "LAPOR-BRANTAS New Disposition"; msg.Body = model.StaffComment; msg.From = new MailAddress("*****@*****.**"); using (var client = new SmtpClient() { Host = "relay-hosting.secureserver.net", Port = 25, EnableSsl = false, UseDefaultCredentials = false }) { client.Send(msg); } } } } catch (Exception ex) { } return(RedirectToAction("Index")); }