Inheritance: System.Web.UI.Page
        public ActionResult Submit(string name, string email, string comment)
        {
            var contactUs = new ContactUs();

            contactUs.Name = name;
            contactUs.Email = email;
            contactUs.Comments = HttpUtility.HtmlDecode(comment);

            var contactUsData = new ContactUsData();
            mapper.Map(contactUs, contactUsData);

            HttpHelper.Post(string.Format(serviceBaseUri+"/ContactUs"), contactUsData);
            return View("Index");
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            ContactUs entity = new ContactUs();

              entity.Name = txtName.Text;
              entity.Email = txtEmail.Text;
              if (txtUrl.Text.Trim() != URL_START)
            entity.Url = txtUrl.Text;
              entity.Message = txtMsg.Text;

              // Show the message area
              divMessageArea.Visible = true;

              System.Diagnostics.Debugger.Break();
        }
Esempio n. 3
0
        public MvcMailMessage ContactUsFollowUp(ContactUs contact)
        {
            ViewBag.ContactName = contact.Name;
            ViewBag.ContactEmail = contact.Email;
            ViewBag.ContactPhoneNumber = contact.Phone;
            ViewBag.ContactMessage = contact.Message;
            ViewBag.ContactSubject = contact.Subject;

            const string destination = "*****@*****.**";

            return Populate(x =>
            {
                x.Subject = "New Contact Us Request";
                x.To.Add(destination);
                x.ViewName = "ContactUsFollowUp";
            });
        }
        public void sendContactUs(int currentUserId, string ipAddress, WebContactUs webContactUs)
        {
            ContactUs contactUs = new ContactUs();
            contactUs.date = DateTime.UtcNow;
            contactUs.userId = currentUserId;
            contactUs.ipAddress = ipAddress;

            contactUs.firstName = webContactUs.firstName;
            contactUs.lastName = webContactUs.lastName;
            contactUs.emailAddress = webContactUs.emailAddress;
            contactUs.phone = webContactUs.phone;
            contactUs.message = webContactUs.message;

            db.ContactUsSubmissions.Add(contactUs);
            db.SaveChanges();

            Email.sendContactUs(receiver, contactUs);
        }
Esempio n. 5
0
        //[ApiAuthFilter]

        public IHttpActionResult SendMessageToPickC(ContactUs contactUs)
        {
            try
            {
                contactUs.CreatedBy = UTILITY.DEFAULTUSER;
                bool   result   = new CustomerBO().SaveCustomer(contactUs);
                string fromMail = string.Empty;
                if (result == true)
                {
                    if (contactUs.Type == "CustomerSupport" || contactUs.Type == "FeedBack")
                    {
                        fromMail = "*****@*****.**";
                    }
                    else if (contactUs.Type == "ContactUs" || contactUs.Type == "Careers")
                    {
                        fromMail = "*****@*****.**";
                    }
                    bool sendMail = new EmailGenerator().ConfigMail(fromMail, true, contactUs.Subject, contactUs.Message);

                    if (sendMail)
                    {
                        return(Ok("Mail Sent Successfully!"));
                    }
                    else
                    {
                        return(NotFound());
                    }
                }
                else
                {
                    return(NotFound());
                }
            }
            catch (Exception exception)
            {
                return(InternalServerError(exception));
            }
        }
        public async Task <IActionResult> Register(ContactUsViewModel registerContact, CancellationToken cancellationToken)
        {
            model = await _aboutUsService.GetAboutUs(CancellationToken.None);

            if (!ModelState.IsValid)
            {
                ViewData["AboutData"] = model;
                return(View("Contact"));
            }
            try
            {
                string hostName = Dns.GetHostName();
                string ip       = Dns.GetHostByName(hostName).AddressList[0].ToString();

                ContactUs contact = new ContactUs
                {
                    Email      = registerContact.contactUs.Email,
                    InsertDate = DateTime.Now,
                    IsRead     = 0,
                    FullName   = registerContact.contactUs.FullName.Trim(),
                    Comment    = registerContact.contactUs.Comment.Trim(),
                    IP         = ip
                };

                await _contactUsService.RegisterContact(contact, cancellationToken);

                ViewData["message"]   = "پیام شما با موفقیت ثبت شد";
                ViewData["AboutData"] = model;
                return(View("Contact"));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "خطایی در سیستم بوجود آمده است");
                ViewData["message"]   = "خطایی در سیستم به وجود آمده است. لطفا در زمان دیگری مجددا تلاش بفرمایید";
                ViewData["AboutData"] = model;
                return(View("Contact"));
            }
        }
        public void AddContact(ContactUs contact)
        {
            using (var cn = new SqlConnection(Settings.GetConnectionString()))
            {
                SqlCommand cmd = new SqlCommand("AddContact", cn);
                cmd.CommandType = CommandType.StoredProcedure;

                SqlParameter param = new SqlParameter("@ContactUsId", SqlDbType.Int);
                param.Direction = ParameterDirection.Output;
                cmd.Parameters.Add(param);

                cmd.Parameters.AddWithValue("@ContactUsFirstName", contact.ContactUsFirstName);
                cmd.Parameters.AddWithValue("@ContactUsLastName", contact.ContactUsLastName);
                if (string.IsNullOrEmpty(contact.ContactUsEmail))
                {
                    cmd.Parameters.AddWithValue("@ContactUsEmail", DBNull.Value);
                }
                else
                {
                    cmd.Parameters.AddWithValue("@ContactUsEmail", contact.ContactUsEmail);
                }
                if (string.IsNullOrEmpty(contact.ContactUsPhone))
                {
                    cmd.Parameters.AddWithValue("@ContactUsPhone", DBNull.Value);
                }
                else
                {
                    cmd.Parameters.AddWithValue("@ContactUsPhone", contact.ContactUsPhone);
                }
                cmd.Parameters.AddWithValue("@ContactUsMessage", contact.ContactUsMessage);

                cn.Open();

                cmd.ExecuteNonQuery();

                contact.ContactUsId = (int)param.Value;
            }
        }
Esempio n. 8
0
        public ActionResult Contact(ContactUs contact)
        {
            // credintial email to used in smtp client(send msg to destination email from this mail)
            var middlemail = new NetworkCredential("*****@*****.**", "jobby@93");  //(1)

            //create msg object to form msg body(to,from,subj,msgtext) (2)
            var mail = new MailMessage();

            if (ModelState.IsValid)
            {
                //fill msg field
                mail.From = new MailAddress(contact.Mail);
                mail.To.Add(new MailAddress("*****@*****.**"));
                mail.Subject    = contact.Subject;
                mail.IsBodyHtml = true;                   // to send html tags
                string body = "<q>" + contact.Message + "</q>" + "<br>" + "<br>" + "By : " + "<b>" + contact.Name + "</b>" + "<br>" +

                              "E-mail Address : " + contact.Mail;
                mail.Body = body;
            }


            ///// we can send it only throw smtpClient  (3)
            try
            {
                SmtpClient SC = new SmtpClient("smtp.gmail.com", 587);
                SC.EnableSsl   = true;
                SC.Credentials = middlemail;
                SC.Send(mail);
                return(RedirectToAction("index"));
            }

            catch
            {
                ViewBag.net = "Check internet Connection and Resend it Again";
            }
            return(View(contact));
        }
Esempio n. 9
0
        public void AddContact(ContactUs contact)
        {
            using (_ctx)
            {
                ContactUs info = new ContactUs();

                info.Name    = contact.Name;
                info.Email   = contact.Email;
                info.Phone   = contact.Phone;
                info.Message = contact.Message;

                if (string.IsNullOrEmpty(info.Email) && !string.IsNullOrEmpty(info.Phone))
                {
                    info.Email = "";
                }

                if (string.IsNullOrEmpty(info.Phone) && !string.IsNullOrEmpty(info.Email))
                {
                    info.Phone = "";
                }
                _ctx.SubmitContactUs(info.Name, info.Email, info.Phone, info.Message);
            }
        }
Esempio n. 10
0
        public void UpdateContactUs(ContactUs value)
        {
            System.Data.SqlClient.SqlCommand    cmdSQL = null;
            System.Data.SqlClient.SqlConnection cnSQL  = null;

            string ConnString = System.Configuration.ConfigurationManager.ConnectionStrings["SteppingStoneDB"].ConnectionString;

            try
            {
                cnSQL = new System.Data.SqlClient.SqlConnection(ConnString);
                cnSQL.Open();
                cmdSQL             = new System.Data.SqlClient.SqlCommand();
                cmdSQL.Connection  = cnSQL;
                cmdSQL.CommandType = CommandType.Text;

                cmdSQL.CommandText = String.Format("UPDATE ContactUs SET Title = '{0}', Description = '{1}' where Id = {2}", value.Title, value.Description, value.Id);
                cmdSQL.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 11
0
        public void AddContactUs(ContactUs value)
        {
            System.Data.SqlClient.SqlCommand    cmdSQL = null;
            System.Data.SqlClient.SqlConnection cnSQL  = null;

            string ConnString = System.Configuration.ConfigurationManager.ConnectionStrings["SteppingStoneDB"].ConnectionString;

            try
            {
                cnSQL = new System.Data.SqlClient.SqlConnection(ConnString);
                cnSQL.Open();
                cmdSQL             = new System.Data.SqlClient.SqlCommand();
                cmdSQL.Connection  = cnSQL;
                cmdSQL.CommandType = CommandType.Text;

                cmdSQL.CommandText = String.Format("INSERT INTO ContactUs (Title, Description) VALUES ('{0}', '{1}')", value.Title, value.Description);
                cmdSQL.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 12
0
 public async Task <bool> ContactUs(string key, [FromBody] ContactUs obj)
 {
     try
     {
         if (key == "73l3M3D")
         {
             if (obj is null)
             {
                 return(false);
             }
             return(await _messengerService.SendContactUsEmailAsync(obj, Request.Scheme + "://" + Request.Host.Value));
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         _logger.LogError($"file: MessengerController.cs method: SendEmailPatientReport() error: {ex.Message} ");
         return(false);
     }
 }
Esempio n. 13
0
        public void InsertContact(ContactUs contact)
        {
            using (var cn = new SqlConnection(Settings.GetConnectionString()))
            {
                SqlCommand cmd = new SqlCommand("InsertContact", cn);
                cmd.Connection  = cn;
                cmd.CommandType = System.Data.CommandType.StoredProcedure;

                cn.Open();

                var param = new DynamicParameters();
                param.Add("@ContactId", dbType: DbType.Int32, direction: ParameterDirection.Output);

                param.Add("@ContactName", contact.ContactName);
                param.Add("@Phone", contact.Phone);
                param.Add("@Email", contact.Email);
                param.Add("@ContactMessage", contact.ContactMessage);

                cn.Execute("InsertContact", param, commandType: CommandType.StoredProcedure);

                contact.ContactId = param.Get <int>("@ContactId");
            }
        }
Esempio n. 14
0
        public async Task <IResponse <ContactUs> > UpdateAsync(ContactUs model)
        {
            var findedContactUs = await _appUow.ContactUsRepo.FindAsync(model.ContactUsId);

            if (findedContactUs == null)
            {
                return new Response <ContactUs> {
                           Message = ServiceMessage.RecordNotExist.Fill(DomainStrings.ContactUs)
                }
            }
            ;

            findedContactUs.FullName     = model.FullName;
            findedContactUs.Subject      = model.Subject;
            findedContactUs.MobileNumber = model.MobileNumber;
            findedContactUs.Content      = model.Content;

            var saveResult = await _appUow.ElkSaveChangesAsync();

            return(new Response <ContactUs> {
                Result = findedContactUs, IsSuccessful = saveResult.IsSuccessful, Message = saveResult.Message
            });
        }
        public void Send(ContactUs data)
        {
            ValidateInput(data);

            StringBuilder body = new StringBuilder();

            body.AppendFormat("<div>Name: {0}</div>", data.Name);
            body.AppendFormat("<div>Address: {0}</div>", data.Address);
            body.AppendFormat("<div>Town: {0}</div>", data.Town);
            body.AppendFormat("<div>Phone: {0}</div>", data.Phone);
            body.AppendFormat("<div>Email: {0}</div>", data.Email);
            body.AppendFormat("<div>Comments:</div><p>{0}</p>", data.Comments);

            SiteMessage siteMessage = new SiteMessage()
            {
                From    = data.Email,
                To      = ConfigurationManager.AppSettings["ContactUsEmailAddress"],
                Subject = ConfigurationManager.AppSettings["ContactUsEmailSubject"],
                Body    = body.ToString()
            };

            mailAdapter.Send(siteMessage);
        }
Esempio n. 16
0
        public string ContactUs(string Name, string Email, string Phone, string Subject, string comment, bool ContactMe)
        {
            try
            {
                ContactUs ContactUs = new ContactUs();
                ContactUs.Comment      = comment;
                ContactUs.ContactMe    = ContactMe;
                ContactUs.EmailAddress = Email;
                ContactUs.FullName     = Name;
                ContactUs.PhoneNumber  = Phone;
                ContactUs.Subject      = Subject;

                EmailController EmailServer = new EmailController(ConstantRepository);
                EmailServer.ContactUs(ContactUs);
                //TempData["ContactUsEmailReturnMsg"] = "Email sent successfully";
                return("Email sent successfully");
            }
            catch (Exception ex)
            {
                // TempData["ContactUsEmailReturnMsg"] = "Error sending email";
                return("Error sending email");
            }
        }
Esempio n. 17
0
        public async Task ContactUsSendEmailAsync(ContactUs contactUs)
        {
            EmailMessage emailMessage = new EmailMessage
            {
                Subject       = "Request for Contact details from " + contactUs.Name,
                Content       = contactUs.Message + "</br>" + "Name " + contactUs.Name + "</br>" + "Email " + contactUs.Email + "</br>" + "",
                FromAddresses = new List <EmailAddress> {
                    new EmailAddress
                    {
                        Address = "*****@*****.**"
                    }
                },
                ToAddresses = new List <EmailAddress> {
                    new EmailAddress
                    {
                        Name    = "RK",
                        Address = "*****@*****.**",
                    }
                }
            };

            await this.emailService.Send(emailMessage);
        }
        public static bool Create(ContactModel contactModel)
        {
            using (var client = new LandauPortalWebAPI())
            {
                var contactUs = new ContactUs();

                contactUs.Address = new Address()
                {
                    City    = contactModel.City,
                    State   = contactModel.State,
                    Street1 = contactModel.Address,
                    Zipcode = contactModel.ZipCode
                };

                contactUs.Comments  = contactModel.Comments;
                contactUs.Email     = contactModel.Email;
                contactUs.FirstName = contactModel.FirstName;
                contactUs.LastName  = contactModel.LastName;
                contactUs.Phone     = contactModel.PhoneNumber;
                contactUs.Brand     = contactModel.Brand;

                try
                {
                    client.ContactUs.CreateContactUs(contactUs.Brand, contactUs);
                    return(true);
                }
                catch (Exception e)
                {
                    if (e is HttpOperationException)
                    {
                        var httpEx = (HttpOperationException)e;
                        return(httpEx.Response.IsSuccessStatusCode);
                    }
                }
                return(false);
            }
        }
Esempio n. 19
0
        public ActionResult Index(ContactUs c)
        {
            if (ModelState.IsValid)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("Name: " + c.Name + "\r\n");
                sb.Append("Phone: " + c.Phone + "\r\n");
                sb.Append("Email: " + c.EMail + "\r\n\r\n");

                if ((c.Comments == null) || (c.Comments.Length == 0))
                {
                    sb.Append("There were no comments in this email.");
                }
                else
                {
                    sb.Append("Comments/Questions:\r\n\r\n");
                    sb.Append(c.Comments);
                }
                string body = sb.ToString();

                MailMessage msg = new MailMessage("*****@*****.**", "*****@*****.**",
                                                  "Contact information from Student Registration", body);

                SmtpClient smtp = new SmtpClient("mail.ctsoftwaresystems.com", 587);
                System.Net.NetworkCredential eMailPW = new System.Net.NetworkCredential("*****@*****.**", "mSHt6Pq");
                smtp.UseDefaultCredentials = false;
                smtp.Credentials           = eMailPW;

                smtp.Send(msg);

                return(View("EmailSuccess"));
            }
            else
            {
                return(View());
            }
        }
        public async Task <IHttpActionResult> PostContactUs(ContactUsDTO contact)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            ContactUs contactUs = new ContactUs()
            {
                ContactusId = Guid.NewGuid().ToString().Replace('-', ' '),
                Name        = contact.Name,
                Email       = contact.Email,
                Message     = contact.Message,
                Subject     = contact.Subject,
                Mobile      = contact.Mobile
            };

            db.ContactUs.Add(contactUs);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (ContactUsExists(contactUs.ContactusId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = contactUs.ContactusId }, contactUs));
        }
Esempio n. 21
0
        public IActionResult Index(ContactUs vm)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    MailMessage msz = new MailMessage();
                    msz.From = new MailAddress(vm.Email); //Email which you are getting
                                                          //from contact us page
                    msz.To.Add("*****@*****.**");   //Where mail will be sent
                    msz.Subject = vm.Subject;
                    msz.Body    = vm.Message;
                    SmtpClient smtp = new SmtpClient();

                    smtp.Host = "smtp.gmail.com";

                    smtp.Port = 587;

                    smtp.Credentials = new System.Net.NetworkCredential
                                           ("*****@*****.**", "Testpassword123");

                    smtp.EnableSsl = true;

                    smtp.Send(msz);

                    ModelState.Clear();
                    ViewBag.Message = "Thank you for Contacting us ";
                }
                catch (Exception ex)
                {
                    ModelState.Clear();
                    ViewBag.Message = $" Sorry we are facing Problem here {ex.Message}";
                }
            }

            return(View());
        }
        public ActionResult Edit([Bind(Include = "Id,Image,Address,Tel,Email,AboutUs,ShortAboutUs,NotShow")] ContactUs contactUs, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                if (file != null)
                {
                    Random randomm = new Random();
                    string imgcode = randomm.Next(100000, 999999).ToString();

                    file.SaveAs(HttpContext.Server.MapPath("~/Images/AboutUs/") + imgcode.ToString() + "-" + file.FileName);
                    contactUs.Image = imgcode.ToString() + "-" + file.FileName;
                }
                contactUs.InsertUser      = "******";
                contactUs.InsertDate      = DateTime.Now;
                contactUs.UpdateUser      = "******";
                contactUs.UpdateDate      = DateTime.Now;
                contactUs.IsArchived      = false;
                contactUs.IsDeleted       = false;
                db.Entry(contactUs).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(contactUs));
        }
        public ActionResult SaveContact([System.Web.Http.FromBody] ContactUsModel model)
        {
            if (model == null)
            {
                throw new ArgumentNullException();
            }

            if (Validator.validate(model))
            {
                try
                {
                    // model mapping (TODO: use automapper here)
                    ContactUs mappedModel = new ContactUs
                    {
                        Id            = Guid.NewGuid(),
                        Name          = model.Name,
                        Email         = model.Email,
                        Mobile        = model.Mobile,
                        MessageTypeId = model.MessageTypeId,
                        Message       = model.Message,
                        FilePath      = model.FilePath,
                        CreateDate    = DateTime.Now
                    };

                    _contactUsRepository.Add(mappedModel);

                    return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
                }
                catch (Exception)
                {
                    return(Json(new { success = false, message = "Unable to save, please try again later." }, JsonRequestBehavior.AllowGet));
                }
            }

            return(Json(new { success = false, message = "Unable to save, please try again later." }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 24
0
        public async Task <IActionResult> DetailsPage(int Id, CancellationToken cancellationToken)
        {
            try
            {
                ContactUs details = await _ContactUsService.TableNoTracking
                                    .FirstOrDefaultAsync(e => e.Id == Id && !e.IsDeleted, cancellationToken);

                details.IsVisited = true;
                await _ContactUsService.UpdateAsync(details, cancellationToken);

                DetailContactUsDto model = new DetailContactUsDto
                {
                    FullName = details.FullName,
                    Content  = details.Content,
                    Subject  = details.Subject,
                };
                return(PartialView("_ContentPage", model));
            }

            catch (Exception ex)
            {
                return(new JsonResult(new { items = false, message = OperationMessage.OperationFailed.ToDisplay() }));
            }
        }
Esempio n. 25
0
        public async Task <ActionResult> Create([Bind(Include = "ContactUsId,Name,Email,Tel,Message,")] ContactUs contactUs)
        {
            if (ModelState.IsValid)
            {
                //default values
                contactUs.Read = false;

                //setting the time based on IR time zone
                var            info            = TimeZoneInfo.FindSystemTimeZoneById("Iran Standard Time");
                DateTimeOffset localServerTime = DateTimeOffset.Now;
                DateTimeOffset localTime       = TimeZoneInfo.ConvertTime(localServerTime, info);
                contactUs.SubmitDateTime = localTime.DateTime;


                db.ContactUses.Add(contactUs);
                await db.SaveChangesAsync();

                //return RedirectToAction("Index");
                return(Json(new { status = "Success" }, JsonRequestBehavior.AllowGet));
            }

            //return View(contactUs);
            return(Json(new { status = "Failed" }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 26
0
 public void LandingPage_TestContactUs_WS_1151()
 {
     if (!DataParser.ReturnExecution("WS_1048"))
     {
         Assert.Ignore();
     }
     else
     {
         ContactUs contactUsPage = InitialPage.Go().ClickContactUs();
         Assert.IsTrue(contactUsPage.Is1stNameTxtAvl(), "The label is not correct");
         Assert.IsTrue(contactUsPage.IsLastNameTxtAvl(), "The label is not correct");
         Assert.IsTrue(contactUsPage.IsEmailTxtAvl(), "email field is not available");
         Assert.AreEqual("Access - Password", contactUsPage.GetInquiryOpts(0), "Option is not correct");
         Assert.AreEqual("Access - Username", contactUsPage.GetInquiryOpts(1), "Option is not correct");
         Assert.AreEqual("Access - Non Registered User", contactUsPage.GetInquiryOpts(2), "Option is not correct");
         Assert.AreEqual("Access - Email Address", contactUsPage.GetInquiryOpts(3), "Option is not correct");
         Assert.AreEqual("Gift Certificate - Balance", contactUsPage.GetInquiryOpts(4), "Option is not correct");
         Assert.AreEqual("Gift Certificate - Add Value", contactUsPage.GetInquiryOpts(5), "Option is not correct");
         Assert.AreEqual("Gift Certificate - History", contactUsPage.GetInquiryOpts(6), "Option is not correct");
         Assert.AreEqual("Gift Certificate - Activation Status", contactUsPage.GetInquiryOpts(7),
                         "Option is not correct");
         Assert.AreEqual("Gift Certificate - Order Status", contactUsPage.GetInquiryOpts(8),
                         "Option is not correct");
         for (int i = 4; i < 9; i++)
         {
             contactUsPage.SelectInquiryOption(contactUsPage.GetInquiryOpts(i));
             Assert.IsTrue(contactUsPage.IsOrderIDAvl(), "Order id field is not available");
             Assert.IsTrue(contactUsPage.IsYearAvl(), "Order id field is not available");
             Assert.IsTrue(contactUsPage.IsMonthIDAvl(), "Order id field is not available");
             Assert.IsTrue(contactUsPage.IsDayAvl(), "Order id field is not available");
         }
         Assert.AreEqual("Other", contactUsPage.GetInquiryOpts(9), "Option is not correct");
         Assert.IsTrue(contactUsPage.IsMsgInquiryAvl(), "continue button is not available");
         Assert.AreEqual("SUBMIT", contactUsPage.GetSubmitBtnTxt(), "The label is not correct");
     }
 }
Esempio n. 27
0
 public HttpStatusCodeResult ContactUs(ContactUs input)
 {
     try
     {
         using (TouchContext db = new TouchContext())
         {
             if (input.Id > 0)
             {
                 db.Entry(input).State = EntityState.Modified;
             }
             else
             {
                 db.ContactUs.Add(input);
             }
             db.SaveChanges();
         }
     }
     catch (Exception)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError));
         // throw;
     }
     return(new HttpStatusCodeResult(HttpStatusCode.OK));
 }
Esempio n. 28
0
        public async Task <JsonResult> SaveContactUs(string name, string email, string subject, string phone, string message)
        {
            ContactUs contactUs = new ContactUs();

            contactUs.Name    = name;
            contactUs.Email   = email;
            contactUs.Phone   = phone;
            contactUs.Subject = subject;
            contactUs.Message = message;


            _context.Add(contactUs);
            int result = await _context.SaveChangesAsync();


            if (result == 1)
            {
                return(Json(true));
            }
            else
            {
                return(Json(false));
            }
        }
        public ActionResult Contact(ContactUs contact)
        {
            using (SqlConnection con = new SqlConnection(connectionstring))
            {
                con.Open();
                string     query = "insert into ContactUs(Name,Email,Telephone,Subject,Message) values(@Name,@Email,@Telephone,@Subject,@Message)";
                SqlCommand cmd   = new SqlCommand(query, con);

                cmd.Parameters.AddWithValue("@Name", contact.Name);

                cmd.Parameters.AddWithValue("@Email", contact.Email);
                //cmd.Parameters.AddWithValue("@roomtype", hotelmodel.roomtype);
                cmd.Parameters.AddWithValue("@Telephone", contact.Telephone);
                cmd.Parameters.AddWithValue("@Subject", contact.Subject);

                cmd.Parameters.AddWithValue("@Message", contact.Message);

                cmd.ExecuteNonQuery();
                //}   // TODO: Add insert logic here
                con.Close();

                return(RedirectToAction("Index"));
            }
        }
Esempio n. 30
0
        public ActionResult Contact(ContactUs contactUs)
        {
            if (ModelState.IsValid)
            {
                ContactUs Contact = new ContactUs();
                Contact.Name    = contactUs.Name;
                Contact.Email   = contactUs.Email;
                Contact.Subject = contactUs.Subject;
                Contact.Message = contactUs.Message;

                try
                {
                    DoctorDBContext.ContactUs.Add(Contact);
                    DoctorDBContext.SaveChanges();
                }
                catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
                {
                    Exception raise = dbEx;
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            string message = string.Format("{0}:{1}",
                                                           validationErrors.Entry.Entity.ToString(),
                                                           validationError.ErrorMessage);
                            // raise a new exception nesting
                            // the current instance as InnerException
                            raise = new InvalidOperationException(message, raise);
                        }
                    }
                    throw raise;
                }
                return(View("Index"));
            }
            return(View(contactUs));
        }
Esempio n. 31
0
        public static void ADOCanAddContact()
        {
            ContactUs contactToAdd = new ContactUs();
            var       repo         = new ContactUsRepositoryADO();

            contactToAdd.ContactUsFirstName = "Sally";
            contactToAdd.ContactUsLastName  = "Rogers";
            contactToAdd.ContactUsEmail     = "*****@*****.**";
            contactToAdd.ContactUsPhone     = "333-333-3333";
            contactToAdd.ContactUsMessage   = "Test3 Lorem ipsum dolor sit amet, consectetur adipiscing elit.";

            repo.AddContact(contactToAdd);
            var contacts = repo.GetAllContactRequests().ToList();

            Assert.IsNotNull(contacts[2]);
            Assert.AreEqual(3, contacts.Count);

            Assert.AreEqual(3, contacts[2].ContactUsId);
            Assert.AreEqual("Sally", contacts[2].ContactUsFirstName);
            Assert.AreEqual("Rogers", contacts[2].ContactUsLastName);
            Assert.AreEqual("*****@*****.**", contacts[2].ContactUsEmail);
            Assert.AreEqual("333-333-3333", contacts[2].ContactUsPhone);
            Assert.AreEqual("Test3 Lorem ipsum dolor sit amet, consectetur adipiscing elit.", contacts[2].ContactUsMessage);
        }
        public IActionResult Contact(ContactUsViewModel contactUsViewModel)
        {
            try
            {
                BusinessLogic.BusinessLogic businessLogic = new BusinessLogic.BusinessLogic();
                ContactUs contactUs = new ContactUs
                {
                    Name        = contactUsViewModel.Name,
                    Email       = contactUsViewModel.Email,
                    Contact     = contactUsViewModel.Contact,
                    Porpose     = contactUsViewModel.Porpose,
                    Description = contactUsViewModel.Description
                };
                int    saveResult  = businessLogic.InsertContactDetail(contactUs);
                string mailMessage = businessLogic.SendMail(contactUsViewModel.Email, ConstantFields.SenderMail, contactUsViewModel.Description, contactUsViewModel.Porpose);

                ViewBag.Message = saveResult > 0 ? "Thank You For Contacting Us" : "!Sorry currently we unable to capture your request";
                return(View(contactUsViewModel));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 33
0
        public ActionResult Contact(ContactUs model)
        {
            try {
                Configuration configurations = Configuration.Create(Db);
                EmailMssg     mssg           = new EmailMssg();
                mssg.IsHtml    = true;
                mssg.Receivers = new List <string>()
                {
                    configurations.ContactFormEmail
                };
                mssg.SenderAddress  = "*****@*****.**";
                mssg.Subject        = "Contact request from " + model.FullName;
                mssg.TemplateModel  = model;
                mssg.TemplateString = System.IO.File.ReadAllText(Server.MapPath("~/Templates/ContactUsTemplate.html"));

                EmailSender.Send(configurations, mssg);
                TempData["success"] = "Your email was successfully sent";
            }
            catch (Exception ex)
            {
                TempData["error"] = "Error while sending email: " + ex.ToString();
            }
            return(View());
        }
Esempio n. 34
0
        public async Task <ActionResult> Contact(ContactUs contactUs)
        {
            // Create the email object first, then add the properties.
            var myMessage = new SendGridMessage();

            // Add the message properties.
            myMessage.From = new MailAddress(contactUs.Email, contactUs.Name);

            // Add multiple addresses to the To field.
            myMessage.AddTo("*****@*****.**");

            myMessage.Subject = contactUs.Subject;

            //Add the HTML and Text bodies
            //myMessage.Html = "<p></p>";
            myMessage.Text = contactUs.Message;

            var credentials = new NetworkCredential(
                ConfigurationManager.AppSettings["mailAccount"],
                ConfigurationManager.AppSettings["mailPassword"]
                );
            var transportWeb = new Web(credentials);

            // Send the email.
            if (transportWeb != null)
            {
                await transportWeb.DeliverAsync(myMessage);
            }
            else
            {
                Trace.TraceError("Failed to create Web transport.");
                await Task.FromResult(0);
            }

            return(Json("success", JsonRequestBehavior.AllowGet));
        }
Esempio n. 35
0
 protected void Page_Load(object sender, EventArgs e)
 {
     queryStringId = GeneralExtensions.GetQueryStringId();
     contactUs = contactUsRepository.GetContactUsContent(queryStringId);
     hdnContentId.Value = queryStringId.ToString();
 }
 /// <summary>
 /// Add contact us data to DB
 /// </summary>
 /// <param name="n">Contact</param>
 /// 
 internal void addContactUsData(ContactModel n)
 {
     ContactUs c = new ContactUs();
     c.posted = DateTime.Now;
     c.unread = true;
     c.subj = n.subj;
     c.txt = n.txt;
     c.email = n.email;
     db.ContactUs.InsertOnSubmit(c);
     db.SubmitChanges();
 }
Esempio n. 37
0
    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        string redirectPage = null;
        try
        {
            ContactUs info = new ContactUs();

            info.Title = txtTitle.Text.Trim();
            info.Description = txtDescription.Value.Trim();

            info.Name = txtName.Text.Trim();
            info.Email = txtEmail.Text.Trim();
            info.CreatedBy = null;

            if (contactUsOperator.Add(info))
            {
                redirectPage = Utility.AppendQueryString(PagesPathes.ConfirmInsert, new KeyValue(CommonStrings.BackUrl, CommonStrings.ViewDefault));
            }
            else
            {
                redirectPage = Utility.AppendQueryString(PagesPathes.ErrorPage, new KeyValue(CommonStrings.BackUrl, CommonStrings.ViewDefault));
            }
        }
        catch
        {
            redirectPage = Utility.AppendQueryString(PagesPathes.ErrorPage, new KeyValue(CommonStrings.BackUrl, CommonStrings.ViewDefault));
        }
        finally
        {
            Response.Redirect(redirectPage);
        }
    }