public async Task <IActionResult> Send([FromBody] EmailModel emailModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await _emailComponent.Send(emailModel); return(Ok()); }
public ActionResult CollaborateEdit(CollaborateEditModel model) { model.NguoiDi = int.Parse(Session["userid"].ToString()); var collaborate = _dataService.CollaborateCommand(model); if (model.SendMail) { var sModel = new SendMailModel(); var domain = string.Format(Functiontring.ReturnStringFormatthongtincauhinhmail("domain")); sModel.TieuDe = model.TieuDe; sModel.TuNgay = model.TuNgay; sModel.DenNgay = model.DenNgay; sModel.MoTa = model.MoTa; string chuoicongtruong = ""; string[] macongtruong = model.NoiCongTac.Split(','); for (int i = 0; i < macongtruong.Length; i++) { var congtruong = _dataService.GetListAllPhongbanCongtruongbyID(macongtruong[i].ToString()); if (congtruong.Count > 0 && i < (macongtruong.Length - 1)) { chuoicongtruong = chuoicongtruong + congtruong[0].tenphongban + ", "; } if (congtruong.Count > 0 && i == (macongtruong.Length - 1)) { chuoicongtruong = chuoicongtruong + congtruong[0].tenphongban; } } sModel.phongbancongtruongten = chuoicongtruong; // Call Array.Sort method. sModel.AgreeLink = domain + "/Collaborate/ApprovalCollaborate/?" + "id=" + collaborate.Id + "&status=" + 2; sModel.DisagreeLink = domain + "/Collaborate/ApprovalCollaborate/?" + "id=" + collaborate.Id + "&status=" + 3; string content = RenderPartialToString("~/Views/Collaborate/Emails/MailCongTac.cshtml", sModel); var mail = new EmailComponent(); var result = mail.Send(new MailObj() { To = collaborate.EmailNguoiDuyet.Trim(), Subject = "ĐĂNG KÝ Đi CÔNG TÁC", Body = content }); _dataService.ApprovalCollaborate(collaborate.Id, 1); return(Json(result, JsonRequestBehavior.AllowGet)); } return(Json(true, JsonRequestBehavior.AllowGet)); }