public ActionResult Create(TechnicianGroupEditViewModel model) { try { if (model == null) { throw new ArgumentNullException($"新增群組數據-功能時,並未傳入任何信息"); } if (model.Zo == null) { throw new Exception($"並未傳入區域名稱"); } if (model.Accounts == null) { throw new Exception($"並未傳入技師名稱"); } #region 組合區域與課別 //組合區域 string ZO = ""; model.Zo.ForEach(x => { ZO += "," + x; }); if (ZO != "") { ZO = ZO.Substring(1); } //組合課別 string DO = ""; model.Do.ForEach(x => { DO += "," + x; }); if (DO != "") { DO = DO.Substring(1); } #endregion //群組信息 TtechnicianGroup techniciangroup = new TtechnicianGroup() { CompCd = model.CompCd, VendorCd = model.VendorCd, GroupName = model.GroupName, Responsible_Zo = ZO, Responsible_Do = DO, }; Boolean isSuccess = _vendorService.CreateTechnicianGroup(techniciangroup, model.Accounts); return(Json(new JsonResult() { Data = new { IsSuccess = isSuccess, Message = $"新增群組資料:{ (isSuccess ? "成功" : "失敗")} ", } })); } catch (Exception ex) { _logger.Error(ex.Message); if (ex.InnerException != null) { _logger.Error(ex.InnerException.Message); if (ex.InnerException.InnerException != null) { _logger.Error(ex.InnerException.InnerException.Message); } } return(Json(new JsonResult() { Data = new { IsSuccess = false, Message = $"新增群組數據失敗,原因:{ex.Message}" } })); } }