// GET: Profil public ActionResult Show(string id = "") { if (id == "") { ViewBag.info = "Id belum dimasukkan"; return(View("Error")); } else { author = AuthorsModel.getAuthor(id); artikel = ArtikelModel.getArtikelByProfile(id); ViewBag.author = author; ViewBag.artikel = artikel; System.Diagnostics.Debug.Write(author); if (author.is_error) { ViewBag.info = "Id yang anda masukkan tidak vaild atau sedang terjadi kesalahan pada database, silahkan refresh browser atau klik back"; return(View("Error")); } else { return(View()); } } }
public E_Authors getAuthor(String id_profile) { E_Authors profile = new E_Authors(); cmd.Connection = db; cmd.CommandText = "SELECT id_authors,auth_id, author_name author, array_to_string(affiliation,'; ') department FROM irci.authors WHERE id_authors ='" + id_profile + "'"; try { var reader = cmd.ExecuteReader(); while (reader.Read()) { string newauthor = reader["author"].ToString(); if (reader["author"].ToString().Contains(",")) { string[] authorsplit = reader["author"].ToString().Split(','); newauthor = authorsplit[1] + ' ' + authorsplit[0]; } newauthor.Replace("*", ""); profile = new E_Authors() { author_name = newauthor, affiliation = reader["department"].ToString() //id_authors = reader["id_authors"].ToString(), }; } } catch (Exception ex) { System.Diagnostics.Debug.Write(ex); profile.is_error = true; } return(profile); }