private IActionResult ActionComplete(ReservationDetail _detail, int rate, string content)
        {
            if (_detail == null)
            {
                return(RedirectToActionPermanent(nameof(Index)));
            }

            if (_detail.State == ReservationState.Answered)
            {
                _detail.State = ReservationState.Completed;
                _detail.LastUpdatedLanguage = cultureContext.Culture.Language;
                _detail.ActionDate          = DateTimeHelper.GetBeijingTime();
                EntityEntry <ReservationDetail> entry = db.Entry(_detail);
                entry.State = EntityState.Modified;

                ServiceFeedback fb = new ServiceFeedback()
                {
                    Content           = content,
                    Rate              = rate,
                    ReservationDetail = _detail
                };
                db.ServiceFeedBacks.Add(fb);
                db.SaveChanges();
            }
            return(RedirectToActionPermanent(nameof(Detail)));
        }
Exemplo n.º 2
0
 public JsonResult ServiceFeedback(int?locationId, string name, string email, string comment)
 {
     if (locationId.HasValue)
     {
         // Initialize a new instance of ServiceFeedback
         ServiceFeedback serviceFeedback = new ServiceFeedback();
         serviceFeedback.LocationId      = locationId.Value;
         serviceFeedback.Name            = name;
         serviceFeedback.Email           = email;
         serviceFeedback.Comment         = comment;
         serviceFeedback.CreationDate    = DateTime.Now;
         serviceFeedback.MessageStatusId = 1;
         // Insert the new ServiceFeedback to the database
         db.ServiceFeedback.Add(serviceFeedback);
         db.SaveChanges();
         // Send a notification email
         string emailAddress = System.Configuration.ConfigurationManager.AppSettings["ServiceFeedbackEmail"].ToString();
         if ((emailAddress == null) || (emailAddress == ""))
         {
             emailAddress = "*****@*****.**";
         }
         var emailSent = SendEmail(emailAddress, serviceFeedback, serviceFeedback.CreationDate);
         // Redirect the user to the confirmation page
         return(Json(new { url = Url.Content("~/Locations/Done") }));
     }
     else   // redirect the user the main location page
     {
         return(Json(new { url = Url.Content("~/Locations") }));
     }
 }
Exemplo n.º 3
0
        private bool SendEmail(string sendTo, ServiceFeedback model, DateTime creationDate)
        {
            var smtpServer = "mail.connectuspro.com";
            //var yourEmail = "*****@*****.**";
            var yourEmail    = "*****@*****.**";
            var yourPassword = "******";

            var           location = db.Location.Find(model.LocationId);
            var           subject  = "Service feedback left by " + model.Name + (location != null ? " at " + location.LocationName : "") + " in 1800plumber.com at " + creationDate;
            StringBuilder strBody  = new StringBuilder();

            strBody.Append(String.Format("<font face=\"Arial\">Career application details: {0}<br /><br />", DateTime.Now));
            strBody.Append(String.Format("From http://{0}<br />", Request.ServerVariables["HTTP_HOST"]));
            strBody.Append(String.Format("IP Address : {0}<br />", Request.UserHostAddress));
            strBody.Append(String.Format("Name : {0}<br />", model.Name));
            strBody.Append(String.Format("Email : {0}<br />", model.Email));
            strBody.Append(String.Format("Location : {0}<br />", location.LocationName));
            strBody.Append(String.Format("Comment : {0}<br />", model.Comment));
            strBody.Append(String.Format("Subject : {0}<br />", subject));

            //strBody.Append(String.Format("<br /><br /><a href=\"{0}\" target=\"_blank\">Click here to view the application on line</a>", link));

            //strBody.Append(TechSettings + "<br />");
            strBody.Append("</font>");

            using (var mailMessage =
                       new MailMessage(new MailAddress(yourEmail),
                                       new MailAddress(sendTo))
            {
                Subject = subject,
                IsBodyHtml = true,
                Body = strBody.ToString()
            })
            {
                System.Net.NetworkCredential networkCredentials = new System.Net.NetworkCredential(yourEmail, yourPassword);
                using (SmtpClient smtpClient = new SmtpClient()
                {
                    EnableSsl = false,
                    UseDefaultCredentials = false,
                    Credentials = networkCredentials,
                    Host = smtpServer,
                    Port = 25
                })
                {
                    try
                    {
                        smtpClient.Send(mailMessage);
                    }
                    catch (Exception ex)
                    {
                        _message = ex.Message;
                        return(false);
                    }
                }
            }

            return(true);
        }