コード例 #1
0
        public ActionResult BatchSaveContact(List <BatchContacts> model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    ContactRepo.BatchUpdate(model);
                    ContactRepo.UnitOfWork.Commit();
                    return(Json(new { isValid = true, message = HttpUtility.HtmlEncode("客戶聯絡人資料更新成功") }));
                }
                catch (Exception ex)
                {
                    return(Json(new { isValid = false, message = HttpUtility.HtmlEncode("客戶聯絡人儲存失敗。錯誤訊息: " + ex.Message) }));
                }
            }
            var msg = string.Join(" ", ModelState.Values.SelectMany(p => p.Errors).Select(p => p.ErrorMessage));

            return(Json(new { isValid = false, message = HttpUtility.HtmlEncode("客戶聯絡人儲存時,驗證欄位失敗。" + msg) }));
        }