public JsonResult GetContactFormMessage() { try { var contactBusiness = new ContactBusiness(); var messageList = contactBusiness.GetContactFormMessage(); return(Json(messageList, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(ex)); } }
public JsonResult SendContactMessage(Contact contact) { try { var contactBusiness = new ContactBusiness(); contactBusiness.SendContactMessage(contact); var returnMessage = "Mesajınız Başarılı Bir Şekilde İletildi !"; return(Json(returnMessage, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(ex, "Beklenmedik Bir Hata İle Karşılaşıldı !")); } }
protected void gridView_RowInserted(object sender, DevExpress.Web.Data.ASPxDataInsertedEventArgs e) { try { using (SendMailEntities db = new SendMailEntities()) { if (ContactBusiness.checkContactIsExist(e.NewValues["Email"].ToString().Trim())) { Contact contact = new Contact(); contact.Email = e.NewValues["Email"].ToString().Trim(); db.Contacts.Add(contact); db.SaveChanges(); } } } catch (Exception) { throw; } }
protected void btnImportList_Click(object sender, EventArgs e) { try { List <Contact> lst_contact = new List <Contact>(); string FolderPath = ConfigurationManager.AppSettings["FolderPath"]; string FileName = txtNameFileUpload.Text; string Extension = Path.GetExtension(FileName); string FilePath = Server.MapPath(FolderPath + FileName); DataTable dt = ImportExcel.ImportExcel2DataTable(FilePath, Extension); checkBoxListEmail.DataSource = dt; checkBoxListEmail.DataMember = "Email"; checkBoxListEmail.TextField = "Email"; checkBoxListEmail.DataBind(); checkBoxListEmail.SelectAll(); //check save contact new SelectedValueCollection listEmail = checkBoxListEmail.SelectedValues; foreach (String email in listEmail) { if (!ContactBusiness.checkContactIsExist(email) && email != "") { Contact contact = new Contact(); contact.Email = email; lst_contact.Add(contact); } } using (SendMailEntities db = new SendMailEntities()) { db.Contacts.AddRange(lst_contact); db.SaveChanges(); } } catch (Exception v_e) { ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + v_e + "');", true); } }
public ContactController(ContactBusiness contactBusiness) { _contactBusiness = contactBusiness; }
static void Main(string[] args) { try { ContactBusiness objBusiness = Bootstrapper.Init(); Contact c = new Contact { ContactType = ContactType.Business, BusinessName = "Object Frontier Software" }; var addContactResult = objBusiness.AddContact(c); Console.WriteLine("Add Contact result: " + addContactResult); var exisitngContacts = objBusiness.GetContacts(); var contactID = exisitngContacts.Select(con => con.ContactID).FirstOrDefault(); ContactAddress ca = new ContactAddress { ContactID = contactID, City = "ROCHESTER", State = "NY", Street = "Monroe Road", ZipCode = "32345" }; var addContactAddressResult = objBusiness.AddAddress(ca); Console.WriteLine("Add Contact address result: " + addContactAddressResult); var contactDetail = objBusiness.GetContactDetail(contactID); Console.WriteLine("Get Contact detail result: " + Constants.Common.Success); var contactByZipCode = objBusiness.GetContactByZipCode(ca.ZipCode); Console.WriteLine("Get Contact by Zip Code result: " + Constants.Common.Success); //Add Contact c.ContactID = Guid.Empty; c.ContactType = ContactType.Person; c.FirstName = "Ruban"; c.LastName = "Stephen"; var addContactWithAddressResult = objBusiness.AddContact(c); Console.WriteLine("Add Contact with address result: " + addContactWithAddressResult); exisitngContacts = objBusiness.GetContacts(); foreach (var address in contactDetail.ContactAddress) { var deleleAddress = objBusiness.DeleteAddress(address.ContactAddressID); Console.WriteLine("Delete address for ContactID: " + contactDetail.ContactID.ToString() + deleleAddress); } foreach (var contact in exisitngContacts) { var deleleStatus = objBusiness.DeleteContact(contact.ContactID); Console.WriteLine("Delete contact for ContactID: " + contact.ContactID.ToString() + deleleStatus); } Console.ReadLine(); } catch (Exception ex) { Console.WriteLine("DAL Test failed due to: " + ex.Message); Console.ReadLine(); } }
public ContactController() { contactBusiness = new ContactBusiness(); }
protected void btnImportList_Click(object sender, EventArgs e) { try { //ListEditItem cmbEmailOwnselectedItem = cmbEmailOwn.SelectedItem; //ListEditItem cmbcmbCampaignselectedItem = cmbCampaign.SelectedItem; SendMailEntities db = new SendMailEntities(); List <TempSendEmail> listTemp = new List <TempSendEmail>(); List <Contact> lst_contact = new List <Contact>(); string FolderPath = ConfigurationManager.AppSettings["FolderPath"]; string FileName = txtNameFileUpload.Text; string Extension = Path.GetExtension(FileName); string FilePath = Server.MapPath(FolderPath + FileName); if (FileName != "") { //delete data in table temporary db.Database.ExecuteSqlCommand("Delete from TempSendEmails where IDUser = "******"STT"].ToString()); temp.Subject = dr["Subject"].ToString(); temp.ContentEmail = dr["Content"].ToString(); temp.Email = dr["Email"].ToString(); temp.IDUser = mGlobal.UserID; temp.TimeSend = DateTime.Now; //temp.IDEmailOwn = Int64.Parse(cmbEmailOwnselectedItem.GetValue("ID").ToString()); //if (cmbCampaign.SelectedIndex > 0) //{ // temp.IDCampaign = Int64.Parse(cmbcmbCampaignselectedItem.GetValue("CampaignID").ToString()); // } listTemp.Add(temp); //check contact, if is not exist then save to db if (!ContactBusiness.checkContactIsExist(temp.Email)) { Contact contact = new Contact(); contact.Email = temp.Email; lst_contact.Add(contact); } } db.TempSendEmails.AddRange(listTemp); if (lst_contact.Count > 0) { db.Contacts.AddRange(lst_contact); } db.SaveChanges(); gridView.DataBind(); } else { String message = "Bạn chưa chọn file hoặc file này đang được mở!"; ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + message + "');", true); } } catch (Exception v_e) { ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + v_e + "');", true); //Debugger.Log(1, "Send Mail", "Failed: " + v_e); } }
public Form1() { InitializeComponent(); this.contactBusiness = new ContactBusiness(); }
public void Setup() { _mock = Bootstrapper.Init(true); }
protected void btnImportList_Click(object sender, EventArgs e) { try { SendMailEntities db = new SendMailEntities(); List <Contact> listContact = new List <Contact>(); string FolderPath = ConfigurationManager.AppSettings["FolderPath"]; string FileName = txtNameFileUpload.Text; string Extension = Path.GetExtension(FileName); string FilePath = Server.MapPath(FolderPath + FileName); if (FileName != "") { DataTable dt = ImportExcel.ImportExcel2DataTable(FilePath, Extension); foreach (DataRow dr in dt.Rows) { Contact contact; if (!ContactBusiness.checkContactIsExist(dr["Email"].ToString().Trim())) { contact = new Contact(); contact.Email = dr["Email"].ToString().Trim(); contact.FirstName = dr["FirstName"].ToString(); contact.LastName = dr["LastName"].ToString(); contact.FullName = dr["FullName"].ToString(); contact.Phone = dr["Phone"].ToString(); contact.Adress = dr["Address"].ToString(); if (dr["Gender"].ToString().Trim().ToUpper().Equals("NỮ")) { contact.Gender = 0; } else { contact.Gender = 1; } contact.Birthday = DateTime.Parse(dr["Birthday"].ToString()); listContact.Add(contact); } else { contact = db.Contacts.FirstOrDefault(x => x.Email == dr["Email"].ToString().Trim()); contact.Email = dr["Email"].ToString().Trim(); contact.FirstName = dr["FirstName"].ToString(); contact.LastName = dr["LastName"].ToString(); contact.FullName = dr["FullName"].ToString(); contact.Phone = dr["Phone"].ToString(); contact.Adress = dr["Address"].ToString(); if (dr["Gender"].ToString().Trim().ToUpper().Equals("NỮ")) { contact.Gender = 0; } else { contact.Gender = 1; } contact.Birthday = DateTime.Parse(dr["Birthday"].ToString()); } } if (listContact.Count > 0) { db.Contacts.AddRange(listContact); } db.SaveChanges(); gridView.DataBind(); } else { String message = "Bạn chưa chọn file hoặc file này đang được mở!"; ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + message + "');", true); } } catch (Exception v_e) { ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + HandleException.SqlExcforContact(v_e) + "');", true); Debugger.Log(1, "Send Mail", "Failed: " + v_e); } }