//
        // GET: /SendEmailInfo/Details/By ID
        public ActionResult Details(int id)
        {
            try
            {
                var sendEmailInfo = _db.SendEmailInfos.Find(id);
                if (sendEmailInfo != null)
                {
                    var sendEmailInfoViewModel = new SendEmailInfoViewModel { SendEmailInfoId = sendEmailInfo.Id, SenderName = sendEmailInfo.SenderName, SenderContactNo = sendEmailInfo.SenderContactNo, Subject = sendEmailInfo.Subject, Message = sendEmailInfo.Message, MemberViewModelId = sendEmailInfo.MemberId, MemberName = sendEmailInfo.Member != null ? sendEmailInfo.Member.FullName : null };

                    return PartialView("_Details", sendEmailInfoViewModel);
                }
                else
                {
                    return RedirectToAction("Index", "SendEmail");
                }

            }
            catch (Exception ex)
            {
                ExceptionHelper.ExceptionMessageFormat(ex, true);
                return RedirectToAction("Index", "SendEmail");
            }
        }
Ejemplo n.º 2
0
        public ActionResult SendEmail(SendEmailInfoViewModel viewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var sendEmailInfo = new SendEmailInfo { SenderName = viewModel.SenderName, SenderContactNo = viewModel.SenderContactNo, Subject = viewModel.Subject, Message = viewModel.Message, MemberId = viewModel.MemberViewModelId };

                    var member = _db.Members.Find(viewModel.MemberViewModelId);
                    var user = _db.Users.Find(member.UserName);
                    var toEmail = user != null ? user.Email : null;
                    var body = viewModel.Message + "Contact No: " + viewModel.SenderContactNo;

                    SendMailHelper sendMailHelper = new SendMailHelper();
                    bool isResult = sendMailHelper.SendEmail(toEmail, viewModel.Subject, body);

                    if (isResult)
                    {
                        _db.SendEmailInfos.Add(sendEmailInfo);
                        _db.SaveChanges();

                        return Content(Boolean.TrueString);
                    }
                    else
                    {
                        return Content("Sorry! Unable to send email to this member.");
                    }

                }

                return Content(ExceptionHelper.ModelStateErrorFormat(ModelState));
            }
            catch (Exception ex)
            {
                ExceptionHelper.ExceptionMessageFormat(ex, true);
                return Content("Sorry! Unable to send email to this member.");
            }
        }
Ejemplo n.º 3
0
        //SendEmail
        public ActionResult SendEmail(int id)
        {
            try
            {
                var member = _db.Members.Find(id);
                if (member != null)
                {
                    var sendEmailInfoViewModel = new SendEmailInfoViewModel { MemberViewModelId = member.Id, MemberName = member.FullName };

                    return PartialView("_SendEmail", sendEmailInfoViewModel);
                }
                else
                {
                    return RedirectToAction("Index", "Donar");
                }

            }
            catch (Exception ex)
            {
                ExceptionHelper.ExceptionMessageFormat(ex, true);
                return RedirectToAction("Index", "Donar");
            }
        }