public IActionResult Edit(MenuPermission model) { AlertBack alert = new AlertBack(); try { if (ModelState.IsValid) { _menuPermissionService.Update(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 PutMenuPermission([FromForm] MenuPermission model, int id = 0) { AlertBack alert = new AlertBack(); if (ModelState.IsValid) { menuPermissionService.Update(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); } }
public IActionResult Update(int id, string fieldName, string value) { AlertBack alert = new AlertBack(); MenuPermission model = _menuPermissionService.Get(id); if (fieldName == "SortOrder") { model.SortOrder = int.Parse(value); } else if (fieldName == "IsCreate") { model.IsCreate = bool.Parse(value); } else if (fieldName == "IsRead") { model.IsRead = bool.Parse(value); } else if (fieldName == "IsUpdate") { model.IsUpdate = bool.Parse(value); } else if (fieldName == "IsDelete") { model.IsDelete = bool.Parse(value); } else if (fieldName == "IsActive") { model.IsActive = bool.Parse(value); } _menuPermissionService.Update(model); alert.Status = "success"; alert.Message = "Updated Successfully"; return(Json(alert)); }