public async Task <IActionResult> GetProjectNumberWithDataA4(string ProjectNumber) { ModelMenuA4ProjectNumberData e = await _IDocMenuAService.GetProjectNumberWithDataA4Async(ProjectNumber); if (e != null) { return(Ok(e)); } else { return(BadRequest()); } }
public async Task <ModelMenuA4ProjectNumberData> GetProjectNumberWithDataA4Async(string project_number) { try { using (SqlConnection conn = new SqlConnection(ConnectionString)) { conn.Open(); using (SqlCommand cmd = new SqlCommand("sp_getdata_for_a4", conn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@project_number", SqlDbType.VarChar, 50).Value = project_number; SqlDataReader reader = await cmd.ExecuteReaderAsync(); if (reader.HasRows) { ModelMenuA4ProjectNumberData e = new ModelMenuA4ProjectNumberData(); while (await reader.ReadAsync()) { e.projectname1 = reader[1].ToString(); e.projectname2 = reader[2].ToString(); e.projectheadname = reader[3].ToString(); e.facultyname = reader[4].ToString(); e.positionname = reader[5].ToString(); e.dateofapproval = reader[7].ToString(); } return(e); } } conn.Close(); } } catch (Exception ex) { throw ex; } return(null); }