public SingleSmallTextModel getCgpaByUserId(int userid, int defaultId)
        {
            SingleSmallTextModel aSingleSmallTextModel = new SingleSmallTextModel();

            using (SqlConnection aSqlConnection
                       = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.CommandText = "get_academics_cgpa";
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("userId", userid);
                    cmd.Parameters.AddWithValue("defaultId", defaultId);
                    cmd.Connection = aSqlConnection;
                    aSqlConnection.Open();
                    SqlDataReader aSqlDataReader = cmd.ExecuteReader();

                    while (aSqlDataReader.Read())
                    {
                        aSingleSmallTextModel.Id = Convert.ToInt32(aSqlDataReader["id"].ToString());
                        aSingleSmallTextModel.RepositorychildId = Convert.ToInt32(aSqlDataReader["repositorychildId"].ToString());
                        aSingleSmallTextModel.Data        = aSqlDataReader["data"].ToString();
                        aSingleSmallTextModel.Description = aSqlDataReader["description"].ToString();
                    }
                }
            }
            return(aSingleSmallTextModel);
        }
Beispiel #2
0
 public HttpResponseMessage UpdateSingleSmallTextModel(int id, [FromBody] SingleSmallTextModel singleSmallTextModel)
 {
     if (singleSmallTextModel == null)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "data with Id = " + id.ToString() + "not found to update"));
     }
     try
     {
         commonGateway.UpdateSingleSmallTextModel(singleSmallTextModel);
         return(Request.CreateResponse(HttpStatusCode.OK, singleSmallTextModel));
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
     }
 }
Beispiel #3
0
        public int UpdateSingleSmallTextModel(SingleSmallTextModel singleSmallTextModel /*int userid, int defaultId*/)
        {
            int returnBool = 0;

            using (SqlConnection aSqlConnection
                       = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.CommandText = "Update_SingleSmallTextModel";
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("id", singleSmallTextModel.Id);
                    cmd.Parameters.AddWithValue("repositorychildId", singleSmallTextModel.RepositorychildId);
                    cmd.Parameters.AddWithValue("data", singleSmallTextModel.Data);
                    cmd.Parameters.AddWithValue("description", singleSmallTextModel.Description);

                    cmd.Parameters.Add("returnBool", SqlDbType.Int);
                    cmd.Parameters["returnBool"].Direction = ParameterDirection.Output;

                    cmd.Connection = aSqlConnection;
                    try
                    {
                        aSqlConnection.Open();
                        Object obj = cmd.ExecuteReader();
                        returnBool = Convert.ToInt32(cmd.Parameters["returnBool"].Value);
                    }
                    catch (Exception ex)
                    {
                        //throw error
                    }

                    /*finally
                     * {
                     *  aSqlConnection.Close();
                     * }*/
                }
            }
            return(returnBool);
        }