public async Task <List <MenuandNavigationDTO> > GetMenuandsubmenulist(string Connectionstring) { var MenuandNavigationDTOList = new List <MenuandNavigationDTO>(); await Task.Run(() => { try { using (NpgsqlDataReader dataReader = NPGSqlHelper.ExecuteReader(Connectionstring, CommandType.Text, "select functionid,parentmodulename,modulename,functionname,functionurl,tf.statusid from tblmstmodules tm join tblmstfunctions tf on tm.moduleid=tf.submoduleid where tf.statusid=" + Convert.ToInt32(Status.Active) + " order by functionid desc; ")) { while (dataReader.Read()) { MenuandNavigationDTO _MenuandNavigationDTO = new MenuandNavigationDTO { pFunctionId = Convert.ToInt64(dataReader["functionid"]), pModulename = Convert.ToString(dataReader["parentmodulename"]), pSubmodulename = Convert.ToString(dataReader["modulename"]), pFunctionname = Convert.ToString(dataReader["functionname"]), pStatusid = Convert.ToString(dataReader["statusid"]), pFunctionurl = Convert.ToString(dataReader["functionurl"]) }; MenuandNavigationDTOList.Add(_MenuandNavigationDTO); } } } catch (Exception) { throw; } }); return(MenuandNavigationDTOList); }
public bool SaveRoleFunction(MenuandNavigationDTO _MenuandNavigationDTO, string Connectionstring) { bool Issaved = false; try { con = new NpgsqlConnection(Connectionstring); if (con.State != ConnectionState.Open) { con.Open(); } trans = con.BeginTransaction(); if (!string.IsNullOrEmpty(_MenuandNavigationDTO.ptypeofoperation)) { string ParentFunctionid = Convert.ToString(_MenuandNavigationDTO.PFunctionParentID); if (_MenuandNavigationDTO.PFunctionParentID == 0) { ParentFunctionid = "null"; } if (_MenuandNavigationDTO.ptypeofoperation.Trim().ToUpper() == "CREATE") { _ = NPGSqlHelper.ExecuteNonQuery(trans, CommandType.Text, cmdText: "INSERT INTO tblmstfunctions (functionparentid,parentmoduleid,submoduleid,functionname,functiondescription,functionurl,isfunctionshowinnavigation,isfunctionallowinroles,statusid,createdby,createddate) VALUES (" + ParentFunctionid + "," + _MenuandNavigationDTO.pModuleId + "," + _MenuandNavigationDTO.pSubmoduleId + ", '" + ManageQuote(_MenuandNavigationDTO.pFunctionname).Trim() + "','','" + ManageQuote(_MenuandNavigationDTO.pFunctionurl).Trim() + "','" + _MenuandNavigationDTO.pIsfunctionshowinNavigation + "','" + _MenuandNavigationDTO.pIsFunctionshowinRoles + "'," + Convert.ToInt32(Status.Active) + ", " + _MenuandNavigationDTO.pCreatedby + ", current_timestamp); "); } else if (_MenuandNavigationDTO.ptypeofoperation.Trim().ToUpper() == "UPDATE") { NPGSqlHelper.ExecuteNonQuery(trans, CommandType.Text, "Update tblmstfunctions set parentmoduleid=" + _MenuandNavigationDTO.pModuleId + ",submoduleid= '" + ManageQuote(_MenuandNavigationDTO.pModulename).Trim() + "', functionname= '" + ManageQuote(_MenuandNavigationDTO.pFunctionname).Trim() + "',functionurl='" + ManageQuote(_MenuandNavigationDTO.pFunctionurl).Trim() + "',isfunctionshowinnavigation='" + _MenuandNavigationDTO.pIsfunctionshowinNavigation + "',isfunctionallowinroles='" + _MenuandNavigationDTO.pIsFunctionshowinRoles + "',modifiedby=" + _MenuandNavigationDTO.pCreatedby + ",modifieddate=current_timestamp,functionparentid=" + ParentFunctionid + " where functionid=" + _MenuandNavigationDTO.pFunctionId + ";"); } else if (_MenuandNavigationDTO.ptypeofoperation.Trim().ToUpper() == "DELETE") { _ = NPGSqlHelper.ExecuteNonQuery(trans, CommandType.Text, cmdText: "update tblmstfunctions set statusid=" + Convert.ToInt32(Status.Inactive) + ",modifiedby=" + _MenuandNavigationDTO.pCreatedby + ",modifieddate=current_timestamp where functionid=" + _MenuandNavigationDTO.pFunctionId + ";"); } trans.Commit(); Issaved = true; } } catch (Exception) { trans.Rollback(); throw; } finally { if (con.State == ConnectionState.Open) { con.Dispose(); con.Close(); con.ClearPool(); trans.Dispose(); } } return(Issaved); }
public IActionResult SaveRoleFunction([FromBody] MenuandNavigationDTO _MenuandNavigationDTO) { try { bool IsValid = false; if (!string.IsNullOrEmpty(_MenuandNavigationDTO.ptypeofoperation)) { if (_MenuandNavigationDTO.ptypeofoperation.Trim().ToUpper() == "CREATE") { if (!string.IsNullOrEmpty(_MenuandNavigationDTO.pModulename) && !string.IsNullOrEmpty(_MenuandNavigationDTO.pSubmodulename) && !string.IsNullOrEmpty(_MenuandNavigationDTO.pFunctionname) && !string.IsNullOrEmpty(_MenuandNavigationDTO.pFunctionurl)) { IsValid = true; } } if (_MenuandNavigationDTO.ptypeofoperation.Trim().ToUpper() == "UPDATE" || _MenuandNavigationDTO.ptypeofoperation.Trim().ToUpper() == "DELETE") { if (Convert.ToString(_MenuandNavigationDTO.pFunctionId) != string.Empty && _MenuandNavigationDTO.pFunctionId > 0) { IsValid = true; } } } if (IsValid) { if (_RolesDAL.SaveRoleFunction(_MenuandNavigationDTO, Con)) { return(Ok(true)); } else { return(StatusCode(StatusCodes.Status304NotModified)); } } else { return(StatusCode(StatusCodes.Status406NotAcceptable)); } } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError)); throw; } }