private void StartLoadContactDetail(int id) { try { var result = ContactsDAL.Get(id); if (result.Code < 0) { lbError.InnerText = result.ErrorMessage; lbError.Visible = true; return; } lbError.Visible = false; //---- ContactBOL BOL = new ContactBOL(result.Data.Tables[0].Rows[0]); lbHeader.InnerText = BOL.Subject_VN; ltrContent.Text = BOL.Content_VN; } catch (Exception ex) { LogHelpers.WriteException("[ContactDetail][StartLoadContactDetail]", ex.ToString()); lbError.InnerText = ex.Message; lbError.Visible = true; } }
public static ResultBOL <int> InsertOrUpdate(ContactBOL contact) { string stored = "sp_Contacts_Insert_Update"; var result = DataAccessHelpers.ExecuteStored(stored, contact.GetParameters()); return(result); }
public void ProcessRequest(HttpContext context) { string tag = "[AddContactHandler][ProcessRequest]"; LogHelpers.WriteStatus(tag, "Start..."); //--- ResultBOL <int> result; try { StreamReader reader = new StreamReader(context.Request.InputStream); string jsonRequest = reader.ReadToEnd(); //--- ContactBOL contact = JsonConvert.DeserializeObject <ContactBOL>(jsonRequest); contact.InsertDate = DateTime.Now; contact.UpdatedDate = DateTime.Now; //-- result = ContactsDAL.InsertOrUpdate(contact); } catch (Exception ex) { LogHelpers.WriteException(tag, ex.ToString()); result = new ResultBOL <int>() { Code = ex.HResult, ErrorMessage = ex.Message }; } string jsonResponse = JsonConvert.SerializeObject(result); context.Response.ContentType = "application/json"; context.Response.Write(jsonResponse); }
public static ResultData <int> InsertOrUpdate(ContactBOL contact) { string stored = "sp_Contacts_Insert_Update"; var result = DataAccessHelpers.ExecuteStored(stored, contact.GetParameters()); if (result.Code < 0) { _log.Error(result.Message); } return(result); }
protected void btnSubmit_Click(object sender, EventArgs e) { string tag = __tag + "[btnSubmit_Click]"; LogHelpers.WriteStatus(tag, "Start..."); ContactBOL contact = StartCreateContact(); try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Utilities.GetApplicationSettingsValue("AddContactWebHandlerUrl")); request.Method = "POST"; request.ContentType = "application/json"; string json = JsonConvert.SerializeObject(contact); byte[] requestBytes = Encoding.Default.GetBytes(json); //--- Stream streamWriter = request.GetRequestStream(); streamWriter.Write(requestBytes, 0, requestBytes.Length); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); StreamReader streamRes = new StreamReader(response.GetResponseStream()); string jsonResponse = streamRes.ReadToEnd(); //--- var result = JsonConvert.DeserializeObject <ResultBOL <int> >(jsonResponse); if (result.Code < 0) { lbError.InnerText = result.ErrorMessage; lbError.Visible = true; } else { lbError.Visible = false; StartClearFormContact(); } } catch (Exception ex) { LogHelpers.WriteException(tag, ex.ToString()); //--- lbError.InnerText = ex.Message; lbError.Visible = true; } }
public ActionResult Contact(ContactBOL model) { #if DEBUG _log.Debug("================ Start ===================="); #endif if (model == null) { return(View(new ContactBOL())); } ResultData <int> result = ContactsDAL.InsertOrUpdate(model); if (result.Code < 0) { ModelState.AddModelError("Error", result.Message); return(View(model)); } return(View(new ContactBOL())); }
private ContactBOL StartCreateContact() { ContactBOL result = new ContactBOL() { Name_VN = tbxName.Text, Address_VN = tbxAddress.Text, Phone = tbxPhone.Text, Email = tbxEmail.Text, Subject_VN = tbxSubject.Text, Content_VN = ckeContent.Text }; if (Utilities.IsLangueEN()) { result.Name_EN = tbxName.Text; result.Address_EN = tbxAddress.Text; result.Subject_EN = tbxSubject.Text; result.Content_EN = ckeContent.Text; } return(result); }
public ActionResult Contact() { ContactBOL contact = ContactsDAL.GetInfo(); return(View(contact)); }