public async Task <List <RolemodulesDTO> > GetallRolesModules(string connectionString) { await Task.Run(() => { _RolemodulesDTOList = new List <RolemodulesDTO>(); try { using (NpgsqlDataReader dataReader = NPGSqlHelper.ExecuteReader(connectionString, CommandType.Text, "select moduleid,modulename from tblmstmodules where coalesce(parentmoduleid,0)=0 and coalesce(parentmodulename,'')='' and statusid=" + Convert.ToInt32(Status.Active) + " order by modulename desc;")) { while (dataReader.Read()) { RolemodulesDTO _RolemodulesDTO = new RolemodulesDTO { pModulename = Convert.ToString(dataReader["modulename"]), pModuleId = Convert.ToInt64(dataReader["moduleid"]) }; _RolemodulesDTOList.Add(_RolemodulesDTO); } } } catch (Exception) { throw; } }); return(_RolemodulesDTOList); }
public IActionResult SaveRoleModule([FromBody] RolemodulesDTO _RolemodulesDTO) { try { if (!string.IsNullOrEmpty(_RolemodulesDTO.pModulename)) { if (_RolesDAL.SaveRoleModule(_RolemodulesDTO, Con)) { return(Ok(true)); } else { return(StatusCode(StatusCodes.Status304NotModified)); } } else { return(StatusCode(StatusCodes.Status406NotAcceptable)); } } catch (Exception) { return(StatusCode(StatusCodes.Status500InternalServerError)); throw; } }
public bool SaveRoleModule(RolemodulesDTO _RolemodulesDTO, string Connectionstring) { bool Issaved = false; try { con = new NpgsqlConnection(Connectionstring); if (con.State != ConnectionState.Open) { con.Open(); } trans = con.BeginTransaction(); _ = NPGSqlHelper.ExecuteNonQuery(trans, CommandType.Text, cmdText: "INSERT INTO tblmstmodules (modulename,moduledescription,statusid,createdby,createddate) VALUES ('" + ManageQuote(_RolemodulesDTO.pModulename).Trim() + "', ''," + Convert.ToInt32(Status.Active) + ", " + _RolemodulesDTO.pCreatedby + ", current_timestamp); "); 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); }