public int SaveAuthor(AuthorModel obj)
        {
            SqlCommand cmd = new SqlCommand("spr_insertAuthor", con);

            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            con.Open();
            cmd.Parameters.AddWithValue("@AuthName", obj.AuthorName);
            cmd.Parameters.AddWithValue("@Description", obj.AuthorDesc);
            int i = cmd.ExecuteNonQuery();

            con.Close();
            return(i);
        }
        public AuthorModel GetAuthorById(int?id)
        {
            AuthorModel obj = new AuthorModel();
            SqlCommand  cmd = new SqlCommand("spr_getAuthorDetailsbyId", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@AuthId", id);
            DataTable      dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(cmd);

            da.Fill(dt);
            foreach (DataRow dr in dt.Rows)
            {
                obj.AuthorId   = Convert.ToInt32(dr[0]);
                obj.AuthorName = Convert.ToString(dr[1]);
                obj.AuthorDesc = Convert.ToString(dr[2]);
            }

            return(obj);
        }
        public List <AuthorModel> GetAuthors()
        {
            List <AuthorModel> listobj = new List <AuthorModel>();
            SqlCommand         cmd     = new SqlCommand("spr_getAuthorDetails", con);

            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable      dt = new DataTable();

            da.Fill(dt);
            foreach (DataRow dr in dt.Rows)
            {
                AuthorModel obj = new AuthorModel();
                obj.AuthorId   = Convert.ToInt32(dr[0]);
                obj.AuthorName = Convert.ToString(dr[1]);
                obj.AuthorDesc = Convert.ToString(dr[2]);
                listobj.Add(obj);
            }

            return(listobj);
        }