/// <summary> /// It Stores Tech Type Data in the Database /// </summary> /// <param name="techStack">Tech Stack</param> /// <returns>If Data Added Successfully return ResponseData else null or Exception</returns> public TechStackResponse AddTechStack(TechStackRequest techStack) { try { TechStackResponse responseData = null; using (SqlConnection conn = new SqlConnection(sqlConnectionString)) { SqlCommand cmd = new SqlCommand("spAddTechStack", conn) { CommandType = System.Data.CommandType.StoredProcedure }; cmd.Parameters.AddWithValue("@TechName", techStack.TechName); cmd.Parameters.AddWithValue("@ImagePath", techStack.ImagePath); cmd.Parameters.AddWithValue("@Framework", techStack.Framework); cmd.Parameters.AddWithValue("@CurrentStatus", techStack.CurrentStatus); cmd.Parameters.AddWithValue("@CreatorStamp", techStack.CreatorStamp); cmd.Parameters.AddWithValue("@CreatorUser", techStack.CreatorUser); cmd.Parameters.AddWithValue("@CreatedDate", DateTime.Now); cmd.Parameters.AddWithValue("@ModifiedDate", DateTime.Now); conn.Open(); SqlDataReader dataReader = cmd.ExecuteReader(); while (dataReader.Read()) { responseData = new TechStackResponse() { ID = Convert.ToInt32(dataReader["ID"]), TechName = dataReader["TechName"].ToString(), ImagePath = dataReader["ImagePath"].ToString(), CurrentStatus = dataReader["CurrentStatus"].ToString(), CreatorStamp = dataReader["CreatorStamp"].ToString(), CreatorUser = dataReader["CreatorUser"].ToString(), CreatedDate = Convert.ToDateTime(dataReader["CreatedDate"]), ModifiedDate = Convert.ToDateTime(dataReader["ModifiedDate"]) }; } conn.Close(); } return(responseData); } catch (Exception ex) { throw new Exception(ex.Message); } }
public List <TechStackResponse> ListOfTechStacks() { try { List <TechStackResponse> techStackList = null; using (SqlConnection conn = new SqlConnection(sqlConnectionString)) { techStackList = new List <TechStackResponse>(); SqlCommand cmd = new SqlCommand("spGetAllTechStacks", conn) { CommandType = System.Data.CommandType.StoredProcedure }; conn.Open(); SqlDataReader dataReader = cmd.ExecuteReader(); while (dataReader.Read()) { TechStackResponse responseData = new TechStackResponse() { ID = Convert.ToInt32(dataReader["ID"]), TechName = dataReader["TechName"].ToString(), ImagePath = dataReader["ImagePath"].ToString(), CurrentStatus = dataReader["CurrentStatus"].ToString(), CreatorStamp = dataReader["CreatorStamp"].ToString(), CreatorUser = dataReader["CreatorUser"].ToString(), CreatedDate = Convert.ToDateTime(dataReader["CreatedDate"]), ModifiedDate = Convert.ToDateTime(dataReader["ModifiedDate"]) }; techStackList.Add(responseData); } conn.Close(); } return(techStackList); } catch (Exception ex) { throw new Exception(ex.Message); } }