public JsonResult ContactUs(string senderName, string senderAddress, string message, string yourphone)
 {
     var mail = new MailMessage(NcConstants.NcEmail, "*****@*****.**")
     {
         Body = string.Format("Sender Name: " + senderName + " SenderAddress: " + senderAddress + "Sender Phone: " + yourphone + "Message: " + message),
         Subject = "Contact Us Message",
         IsBodyHtml = true,
         BodyEncoding = System.Text.Encoding.GetEncoding("utf-8")
     };
     var email = new Email(mail);
     return Json(email.Send() ? new { message = Resource.SuccessMsg} : new { message = Resource.FailureMsg});
 }
 public NC.Data.AccountUser AutoRegisterWhileCreatingPost(NC.Models.AccountUserModel accountUser)
 {
     //create an account user with given info
     PopulateAccountUser(accountUser);
     accountUser.GenerateActivationCode();
     accountUser.GeneratePassword();
     var dataAccountUser = Mapper.Map<NC.Data.AccountUser>(accountUser);
     accountUser = Mapper.Map<NC.Models.AccountUserModel>(_accountUserRepository.RegisterAccountUser(dataAccountUser));
     var mailMessage = accountUser.GetAutoUserCreationMessage();
     var email = new Email(mailMessage);
     email.Send();
     return accountUser;
 }
        public ActionResult ResetPasswordByEmail(UserLogin users)
        {
            if (ModelState.IsValid)
            {
                var result = _accountUserRepository.GetAccountUserByEmailId(users.Email);
                if (result != null && result.Active)
                {
                    var result1 = Mapper.Map<NC.Models.AccountUserModel>(result);
                    result1.GenerateResetPasswordCode();
                    var mailMessage = result1.GetPasswordActivationMessage();
                    var email = new Email(mailMessage);
                    email.Send();
                    ViewBag.message = NcMessage.EmailSentNotification;
                }
                else
                    ViewBag.Error = NcMessage.EmailNotFound + " or " + NcMessage.NotAcitvated;
            }

            return View("ResetPassword");
        }
        public ActionResult RegisterAccount(NC.Models.AccountUserModel accountUser)
        {
            accountUser = PopulateAccountUser(accountUser);
            accountUser.AddressId = NcConstants.DefaultAddressId;
            if (ModelState.IsValid)
            {
                if (_accountUserRepository.IsDuplicateEmail(accountUser.Email))
                {
                    ViewBag.Error = NcMessage.EmailAlreadyExists;
                }
                //To do: Check for valid email id
                //else if (is valid email)
                //{

                //}
                //To do: Check for valid password rule
                //else if (follows password rule)
                //{

                //}
                else
                {
                    accountUser.GenerateActivationCode();
                    var dataAccountUser = Mapper.Map<NC.Data.AccountUser>(accountUser);
                    var user = Mapper.Map<NC.Models.AccountUserModel>(_accountUserRepository.RegisterAccountUser(dataAccountUser));
                    var mailMessage = user.GetUserActivationMessage();
                    var email = new Email(mailMessage);
                    email.Send();
                    ViewBag.SuccessMessage = NcMessage.EmailSentNotification;
                }
            }
            return View("RegisterAccount");
        }
 public JsonResult ReplyToAPost(bool captchaValid, ReplyPost replyPostModel)
 {
     try
     {
         RecaptchaValidator va = new RecaptchaValidator();
         va.Validate();
         if (captchaValid)
         {
             return Json(new { success = "other" });
         }
         else
         {
             var mailMessage = replyPostModel.GetReplyToAPostMessage();
             var email = new Email(mailMessage);
             email.Send();
             return Json(new { success = "true" });
         }
     }
     catch (Exception)
     {
         return Json(new { success = "false" });
     }
 }