public ActionResult UpdateAuthor(EditAuthor editAuthor) { try { if (editAuthor != null) { var author = (Session["AUTHOR"] != null) ? ((Author)Session["AUTHOR"]) : null; if (author != null) { author.username = editAuthor.username; author.profile = editAuthor.profile; var response = new DAO.ProfileController().UpdateAuthor(author.authorId, author).Result; if (response.IsSuccessStatusCode) { var update = response.Content.ReadAsAsync <bool>().Result; if (update == true) { Session["AUTHORID"] = author.authorId; Session.Timeout = 25; Session["AUTHOR"] = author; return(Json(new { success = true, message = "Profile Update Successful" })); } else { new Logger().LogError(ModuleName, "updateAuthorProfile", "Error Updating Author Profile Update false" + "\n"); return(Json(new { success = false, message = "Profile Update Failed, Please Try Again" })); } } else { new Logger().LogError(ModuleName, "UpdateAuthorProfile", "Error UpdateAuthorProfiile - Invalid Credentials or Server Error" + "Status Code: " + response.StatusCode + "\n"); return(Json(new { success = false, message = "Profile Update Failed Status Error, Please Try Again" })); } } else { return(Json(new { success = false, message = "Login To Edit Profile" })); } } else { new Logger().LogError(ModuleName, "updateAuthorProfile", "Error Updating Author Profile " + "\n"); return(Json(new { success = false, message = "Profile Update Failed , Please Provide all necessary Details" })); } } catch (Exception ex) { new Logger().LogError(ModuleName, "updateAuthorProfile", "Error Updating Author Profile " + ex + "\n"); return(Json(new { success = false, message = "Profile Update failed - Server Error, Please Try Again" })); } }
private void изменитьToolStripMenuItem_Click(object sender, EventArgs e) { try { EditAuthor a = new EditAuthor(); a.label_ID.Text = Convert.ToString(dataGridView1[0, dataGridView1.CurrentCell.RowIndex].Value); a.textBox1.Text = Convert.ToString(dataGridView1[1, dataGridView1.CurrentCell.RowIndex].Value); a.ShowDialog(); ShowData(); } catch (Exception) { MessageBox.Show("выберите запись", "ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void editAuthorbtn_Click(object sender, EventArgs e) { try { EditAuthor editAuthor = new EditAuthor(); editAuthor.authorID = Int32.Parse(authorsDataGridView.Rows[authorsDataGridView.SelectedRows[0].Index].Cells[0].Value.ToString()); editAuthor.ShowDialog(); if (isChanged) { InformationForm information = new InformationForm("Selected author is edited.", "Info"); information.Show(); } } catch (ArgumentOutOfRangeException) { MessageBox.Show("Please select a row first!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { this.ViewAuthors_Load(sender, e); } }
private void editAuthorToolStripMenuItem_Click(object sender, EventArgs e) { EditAuthor editAuthorForm = new EditAuthor(this.currentUser, this); editAuthorForm.ShowDialog(); }