//[System.Web.Services.WebMethod] //[ScriptMethod] //[HttpGet] public void Edit_Click(object sender, EventArgs e) { Button btn = (Button)sender; GridViewRow row = (GridViewRow)btn.NamingContainer; int ID = Convert.ToInt32(row.Cells[1].Text); LibraryUI.Models.User model = new LibraryUI.Models.User(); string url; url = "UpdateUser.aspx?ID=" + ID; Response.Redirect(url); //string response = Utilities.Utilities.GetAPICall(Utilities.Utilities.GetAPIPath() + Utilities.Utilities.APIPath.FetchUserByID+"?ID="+ID); //if (response != null) //{ // JsonResponse responseData = JsonConvert.DeserializeObject<JsonResponse>(response); // List<LibraryUI.Models.User> data = JsonConvert.DeserializeObject<List<LibraryUI.Models.User>>(responseData.Data.ToString()); // if (responseData.Status == "S") // { // HttpContext CurrContext = HttpContext.Current; // CurrContext.Items.Add("Data", data); // //Server.Transfer("UpdateUser.aspx"); // string url; // url = "UpdateUser.aspx?ID=" + ID; // Response.Redirect(url); // } //} }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { LibraryUI.Models.User model = new LibraryUI.Models.User(); string response = Utilities.Utilities.GetAPICall(Utilities.Utilities.GetAPIPath() + Utilities.Utilities.APIPath.FetchAllUser); if (response != null) { JsonResponse responseData = JsonConvert.DeserializeObject <JsonResponse>(response); List <LibraryUI.Models.User> data = JsonConvert.DeserializeObject <List <LibraryUI.Models.User> >(responseData.Data.ToString()); DataSet ds = Utilities.Utilities.ToDataSet <LibraryUI.Models.User>(data); GridView1.DataSource = ds; GridView1.DataBind(); if (Session["RoleID"] != null) { if (Convert.ToInt32(Session["RoleID"].ToString()) != 1) { Add_new.Visible = false; //Button3.Visible = false; GridView1.Columns[0].Visible = false; } } } } }
protected void btn_Update_Click(object sender, EventArgs e) { JsonResponse jsonResponse = new JsonResponse(); LibraryUI.Models.User model = new LibraryUI.Models.User(); model.ID = Convert.ToInt64(hidden_id.Text); model.Name = txt_name.Text.ToString(); model.UserName = txt_user_name.Text.ToString(); model.Password = txt_password.Text.ToString(); model.Role = Convert.ToInt32(ddl_role.Text.ToString()); var context = new ValidationContext(model, serviceProvider: null, items: null); var results = new List <ValidationResult>(); var isValid = Validator.TryValidateObject(model, context, results, true); string response = string.Empty; if (model.ID != 0) { response = Utilities.PostAPICallWithParam <LibraryUI.Models.User> .APICall(model, Utilities.Utilities.GetAPIPath() + Utilities.Utilities.APIPath.UpdateUser); } else { response = Utilities.PostAPICallWithParam <LibraryUI.Models.User> .APICall(model, Utilities.Utilities.GetAPIPath() + Utilities.Utilities.APIPath.AddUser); } jsonResponse = JsonConvert.DeserializeObject <JsonResponse>(response); if (jsonResponse.Status == "S") { Server.Transfer("UserSummary.aspx"); } }
public List <LibraryUI.Models.User> FetchData(long ID) { LibraryUI.Models.User model = new LibraryUI.Models.User(); List <LibraryUI.Models.User> data = new List <Models.User>(); string response = Utilities.Utilities.GetAPICall(Utilities.Utilities.GetAPIPath() + Utilities.Utilities.APIPath.FetchUserByID + "?ID=" + ID); if (response != null) { JsonResponse responseData = JsonConvert.DeserializeObject <JsonResponse>(response); data = JsonConvert.DeserializeObject <List <LibraryUI.Models.User> >(responseData.Data.ToString()); } return(data); }
public void Delete_Click(object sender, EventArgs e) { Button btn = (Button)sender; GridViewRow row = (GridViewRow)btn.NamingContainer; int ID = Convert.ToInt32(row.Cells[1].Text); LibraryUI.Models.User model = new LibraryUI.Models.User(); string response = Utilities.Utilities.GetAPICall(Utilities.Utilities.GetAPIPath() + Utilities.Utilities.APIPath.DeleteUSer + "?ID=" + ID); if (response != null) { JsonResponse responseData = JsonConvert.DeserializeObject <JsonResponse>(response); Response.Redirect("UserSummary.aspx"); } }
public void btn_save_Click(object sender, EventArgs e) { JsonResponse jsonResponse = new JsonResponse(); LibraryUI.Models.User model = new LibraryUI.Models.User(); if (txt_user_name.Text != "" && txt_name.Text != "" && txt_password.Text != "" && ddl_role.Text != "") { model.ID = Convert.ToInt64(hidden_id.Text); model.Name = txt_name.Text.ToString(); model.UserName = txt_user_name.Text.ToString(); model.Password = txt_password.Text.ToString(); model.Role = Convert.ToInt32(ddl_role.Text.ToString()); string response = string.Empty; if (model.ID != 0) { response = Utilities.PostAPICallWithParam <LibraryUI.Models.User> .APICall(model, Utilities.Utilities.GetAPIPath() + Utilities.Utilities.APIPath.UpdateUser); } else { response = Utilities.PostAPICallWithParam <LibraryUI.Models.User> .APICall(model, Utilities.Utilities.GetAPIPath() + Utilities.Utilities.APIPath.AddUser); } jsonResponse = JsonConvert.DeserializeObject <JsonResponse>(response); if (jsonResponse.Status == "S") { Server.Transfer("UserSummary.aspx"); } } else { if (txt_name.Text == "") { err_name.Text = "Please Enter Name"; } if (txt_user_name.Text == "") { err_user_name.Text = "Please Enter Username"; } if (txt_password.Text == "") { err_password.Text = "Please Enter Password"; } if (ddl_role.Text == "-1") { err_role.Text = "Please Enter Role"; } } }