public async Task <IActionResult> Edit(Module_PermissionView module_permission) { ResponseHelper objHelper = new ResponseHelper(); if (!ModelState.IsValid) { objHelper.Status = StatusCodes.Status424FailedDependency; objHelper.Message = ModelException.Errors(ModelState); return(BadRequest(objHelper)); } try { if (Module_PermissionRepo.Exists(module_permission)) { objHelper.Status = StatusCodes.Status200OK; objHelper.Message = "Data already available"; return(Ok(objHelper)); } await Module_PermissionRepo.Update(module_permission); objHelper.Status = StatusCodes.Status200OK; objHelper.Message = "Saved Successfully"; return(Ok(objHelper)); } catch (Exception ex) { objHelper.Status = StatusCodes.Status500InternalServerError; objHelper.Message = ex.Message; return(StatusCode(StatusCodes.Status500InternalServerError, objHelper)); } }
public async Task <IActionResult> Add(Module_PermissionView module_permission) { ResponseHelper objHelper = new ResponseHelper(); if (!ModelState.IsValid) { objHelper.Status = StatusCodes.Status424FailedDependency; objHelper.Message = "Invalid Model State"; return(BadRequest(objHelper)); } try { if (Module_PermissionRepo.Exists(module_permission)) { objHelper.Status = StatusCodes.Status200OK; objHelper.Message = "Data already available"; return(Ok(objHelper)); } await Module_PermissionRepo.Insert(module_permission); objHelper.Status = StatusCodes.Status200OK; objHelper.Message = "Saved Successfully"; objHelper.Data = module_permission; return(Ok(objHelper)); } catch { objHelper.Status = StatusCodes.Status500InternalServerError; objHelper.Message = "Save Unsuccessful"; return(StatusCode(StatusCodes.Status500InternalServerError, objHelper)); } }