FIC_Solar/SolarPower/Controllers/SystemUpdateController.cs

53 lines
1.7 KiB
C#

using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
using SolarPower.Repository.Interface;
using SolarPower.Models;
using Microsoft.Extensions.Logging;
using SolarPower.Models.SystemUpdate;
namespace SolarPower.Controllers
{
public class SystemUpdateController : MyBaseController<SystemUpdateController>
{
private readonly IOperationRepository operationRepository;
public SystemUpdateController(IOperationRepository operationRepository) : base()
{
this.operationRepository = operationRepository;
}
public IActionResult Index()
{
return View();
}
[HttpPost]
public async Task<ApiResult<string>> SendNotice(PostSystemUpdate post)
{
ApiResult<string> apiResult = new ApiResult<string>();
#region NoticeSchedule
try
{
var people = await operationRepository.GetAllOperations();
await operationRepository.InsertNoticeSchedule(people, post.Subject, post.Content, post.EmailType);
//sendEmailService.Send(recipientEmails, sendSubject, sendContent);//直接寄信 沒有紀錄
apiResult.Code = "0000";
apiResult.Msg = "已發送到通知行程";
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = errorCode.GetString(apiResult.Code);
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}
#endregion
apiResult.Msg = errorCode.GetString(apiResult.Code);
return apiResult;
}
}
}