public IActionResult Create([FromForm] GeneralSetting model) { AlertBack alert = new AlertBack(); try { if (ModelState.IsValid) { _generalSettingService.Insert(model); alert.Status = "success"; alert.Message = "Register Successfully"; } else { alert.Status = "warning"; foreach (var key in this.ViewData.ModelState.Keys) { foreach (var err in this.ViewData.ModelState[key].Errors) { alert.Message += err.ErrorMessage + "<br/>"; } } } } catch (Exception ex) { alert.Status = "error"; alert.Message = ex.Message; } return(Json(alert)); }
public AlertBack PostGeneralSetting([FromForm] GeneralSetting model) { AlertBack alert = new AlertBack(); if (ModelState.IsValid) { generalSettingService.Insert(model); alert.status = "success"; alert.message = "Register Successfully"; return(alert); } else { alert.status = "warning"; foreach (var key in this.ModelState.Keys) { foreach (var err in this.ModelState[key].Errors) { alert.message += err.ErrorMessage + "<br/>"; } } return(alert); } }