public async Task <IActionResult> UpdateSheduleDate([FromForm] UpdateActionPlanDto obj) { var model = await _actionPlanService.UpdateSheduleDate2(obj.name, obj.value, obj.pk, obj.userid); //var name = obj.name.ToLower(); if (model.Item1.Count > 0 && obj.name == "Title") { Thread thread = new Thread(async() => { string URL = _configuaration.GetSection("AppSettings:URL").ToSafetyString(); var data = model.Item1.DistinctBy(x => x); string content = @"<p><b>*PLEASE DO NOT REPLY* this email was automatically sent from the KPI system.</b></p> <p>The account <b>" + data.First()[0].ToTitleCase() + "</b> changed Title on the task name <b>'" + data.First()[3] + "'</b> </p>" + "<p>Link: <a href='" + _configuration["AppSettings:URL"] + model.Item3 + "'>Click Here</a></p>" + "<br/>" + @"<p><b>*請勿回信*這封信是KPI系統自動寄出.</b></p> <p>帳號<b>" + data.First()[0].ToTitleCase() + "</b> 已經核准了行動方案 <b>'" + data.First()[3] + "'</b> </p>" + "<p>連結: <a href='" + _configuration["AppSettings:URL"] + model.Item3 + "'>點選這裡</a></p>" ; await _mailHelper.SendEmailRange(data.Select(x => x[1]).ToList(), "[KPI System-00] Action Plan (Remark on the task) ", content); }); thread.Start(); } if (model.Item1.Count > 0 && obj.name == "Description") { Thread thread = new Thread(async() => { string URL = _configuaration.GetSection("AppSettings:URL").ToSafetyString(); var data = model.Item1.DistinctBy(x => x); string content = @"<p><b>*PLEASE DO NOT REPLY* this email was automatically sent from the KPI system.</b></p> <p>The account <b>" + data.First()[0].ToTitleCase() + "</b> changed Description on the task name <b>'" + data.First()[3] + "'</b> </p>" + "<p>Link: <a href='" + _configuration["AppSettings:URL"] + model.Item3 + "'>Click Here</a></p>" + "<br/>" + @"<p><b>*請勿回信*這封信是KPI系統自動寄出.</b></p> <p>帳號<b>" + data.First()[0].ToTitleCase() + "</b> 已經核准了行動方案 <b>'" + data.First()[3] + "'</b> </p>" + "<p>連結: <a href='" + _configuration["AppSettings:URL"] + model.Item3 + "'>點選這裡</a></p>" ; await _mailHelper.SendEmailRange(data.Select(x => x[1]).ToList(), "[KPI System-00] Action Plan (Remark on the task) ", content); }); thread.Start(); } if (model.Item1.Count > 0 && obj.name == "Remark") { Thread thread = new Thread(async() => { string URL = _configuaration.GetSection("AppSettings:URL").ToSafetyString(); var data = model.Item1.DistinctBy(x => x); string content = @"<p><b>*PLEASE DO NOT REPLY* this email was automatically sent from the KPI system.</b></p> <p>The account <b>" + data.First()[0].ToTitleCase() + "</b> remarked on the task name <b>'" + data.First()[3] + "'</b> </p>" + "<p>Link: <a href='" + _configuration["AppSettings:URL"] + model.Item3 + "'>Click Here</a></p>" + "<br/>" + @"<p><b>*請勿回信*這封信是KPI系統自動寄出.</b></p> <p>帳號<b>" + data.First()[0].ToTitleCase() + "</b> 已經核准了行動方案 <b>'" + data.First()[3] + "'</b> </p>" + "<p>連結: <a href='" + _configuration["AppSettings:URL"] + model.Item3 + "'>點選這裡</a></p>" ; await _mailHelper.SendEmailRange(data.Select(x => x[1]).ToList(), "[KPI System-00] Action Plan (Remark on the task) ", content); }); thread.Start(); } if (model.Item1.Count > 0 && obj.name == "UpdateSheduleDate") { Thread thread = new Thread(async() => { string URL = _configuaration.GetSection("AppSettings:URL").ToSafetyString(); var data = model.Item1.DistinctBy(x => x); string content = @"<p><b>*PLEASE DO NOT REPLY* this email was automatically sent from the KPI system.</b></p> <p>The account <b>" + data.First()[0].ToTitleCase() + "</b> Change Sheduledate on the task name <b>'" + data.First()[3] + "'</b> </p>" + "<p>Link: <a href='" + _configuration["AppSettings:URL"] + model.Item3 + "'>Click Here</a></p>" + "<br/>" + @"<p><b>*請勿回信*這封信是KPI系統自動寄出.</b></p> <p>帳號<b>" + data.First()[0].ToTitleCase() + "</b> 已經修改了行動方案日期 <b>'" + data.First()[3] + "'</b> </p>" + "<p>連結: <a href='" + _configuration["AppSettings:URL"] + model.Item3 + "'>點選這裡</a></p>" ; await _mailHelper.SendEmailRange(data.Select(x => x[1]).ToList(), "[KPI System-05] Change Sheduledate ", content); }); thread.Start(); } return(Ok(new { status = model.Item2, isSendmail = true })); //return Ok(model); }