public IActionResult Contactus(GetInTouch1 contact1) { ContactHandler handler = new ContactHandler(_configuration); var newGetInTouch1 = handler.AddGetInTouch1(contact1); //contact1.DateCreated = DateTime.Now; return(RedirectToAction("Listing")); }
public object AddGetInTouch1(GetInTouch1 contact1) { DataAccess db = new DataAccess(_configuration); var contacts = db.AddGetInTouch1ToDatabase(contact1); return(contacts); }
public object AddGetInTouch1ToDatabase(GetInTouch1 newGetInTouch1) { string queryString = "INSERT INTO GetInTouch(Name,Email,Contact,Message,DateCreated)Values('" + newGetInTouch1.Name + "','" + newGetInTouch1.Email + "','" + newGetInTouch1.Contact + "','" + newGetInTouch1.Message + "','" + newGetInTouch1.DateCreated + "');"; using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(Helper.BlogConnectionStringValue(_configuration, ConnectionStringName))) { GetInTouch1[] contacts = connection.Query <GetInTouch1>(queryString).ToArray(); return(contacts); } }