Esempio n. 1
0
        public static async Task<bool> SendMailSupport(SupportViewModel data)
        {
            try
            {
                var client = new SmtpClient();
                client.DeliveryMethod = SmtpDeliveryMethod.Network;
                client.EnableSsl = true;

                var adminEmail = ConfigurationManager.AppSettings["GOPLAY_ADMIN_EMAIL_SENDER"];
                var emailSupport = ConfigurationManager.AppSettings["CUSTOMER_SUPPORT_EMAIL_SENDER"];// TODO: have to replace to CUSTOMER_SUPPORT_EMAIL_SENDER when deploy
                var displayName = ConfigurationManager.AppSettings["GOPLAY_ADMIN_EMAIL_NAME"];
                var from = new MailAddress(adminEmail, displayName);
                var to = new MailAddress(emailSupport);

                var mailMessage = new MailMessage(from, to)
                {
                    Subject = string.Format("{0} [From {1}]", data.subject, data.customerEmail),
                    Body = GetEmailBody(ConfigurationManager.AppSettings["SupportTemplate"], data),
                    IsBodyHtml = true
                };
                mailMessage.ReplyToList.Add(data.customerEmail);
                await client.SendMailAsync(mailMessage);
                return true;
            }
            catch
            {
                return false;
            }
        }
Esempio n. 2
0
        public async Task<JsonResult> Support(SupportViewModel model)
        {

            if (ModelState.IsValid)
            {
                var games = Helpers.GameHelper.GetGamesForCurrentUser(CurrentUser);
                string errorMessage = null;
                string errorKey = "";
                if (model.platform == "game")
                {
                    if (model.gameID == null || model.gameID < 0)
                    {
                        errorMessage = Resources.Resources.This_field_is_required;
                        errorKey = "gameID";
                    }
                    else if (games.SingleOrDefault(x => x.id == model.gameID) == null)
                    {
                        errorMessage = "Game is not active or has been removed";
                        errorKey = "gameID";
                    }
                    else if (string.IsNullOrEmpty(model.gameOSName))
                    {
                        errorMessage = Resources.Resources.This_field_is_required;
                        errorKey = "gameOSName";
                    }
                }
                if (model.forValidate && string.IsNullOrEmpty(errorMessage))
                {
                    return Json(new { correct = true });
                }
                else
                {
                    if (!string.IsNullOrEmpty(errorMessage))
                    {
                        ModelState.AddModelError(errorKey, errorMessage);
                    }
                    else
                    {
                        Game game = null;
                        if (model.gameID != null && model.gameID >= 0)
                        {
                            game = games.SingleOrDefault(x => x.id == model.gameID);
                        }
                        model.game = game;
                        await EmailHelper.SendMailSupport(model);
                        return Json(new { success = true, message = "We will contact you soon" });
                    }
                }
                
            }
            return Json(new { errors = Errors(ModelState) });
        }
Esempio n. 3
0
 public ActionResult Support()
 {
     SupportViewModel model = new SupportViewModel();
     if (CurrentUser != null)
     {
         model.customerEmail = CurrentUser.Email;
         model.customerName = CurrentUser.display_name;
     }
     model.listgames = Helpers.GameHelper.GetGamesForCurrentUser(CurrentUser);
     return View(model);
 }