public ActionResult editAuthor(int id, FormCollection collection) { try { Library_BL.Author author = Library_BL.Author.getByAid(id); author.BirthYear = Convert.ToInt16(collection["BirthYear"]); author.FirstName = collection["FirstName"]; author.LastName = collection["LastName"]; author.save(); return(RedirectToAction("ListAuthors")); } catch { return(View()); } }
public static string GetBookISBN(int id) { Library_BL.Author author = Library_BL.Author.getByAid(id); string queryGetBooks = "select * from BOOK_AUTHOR where Aid=" + id; SqlConnection con = new SqlConnection(Settings.ConnectionString); SqlCommand cmd = new SqlCommand(queryGetBooks, con); List <string> isbnList = new List <string>(); try { con.Open(); SqlDataReader dar = cmd.ExecuteReader(); while (dar.Read()) { string isbn = Convert.ToString(dar["ISBN"]); isbnList.Add(isbn); } } catch (Exception er) { throw er; } finally { con.Close(); } int antalBocker = isbnList.Count(); string query = ""; for (int i = 0; i < antalBocker; i++) { if (i != 0) { query += ", "; } query += "'" + isbnList[i] + "'"; } return(query); }