Пример #1
0
        public int SubmitContactEnquiry(ContactEnquiryDTO model)
        {
            ContactEnquiry contact = new ContactEnquiry();

            contact = mapper.Map <ContactEnquiry>(model);
            return(NotificationRepository.SubmitContactEnquiry(contact));
        }
Пример #2
0
        public int PrepareAndSendContactEmail(ContactEnquiryDTO model)
        {
            ActivityLog.SetLog("[START][PrepareAndSendContactEmail]", LogLoc.INFO);
            string body = string.Empty;

            using (StreamReader reader = new StreamReader(System.Web.HttpContext.Current.Server.MapPath("~/Helpers/EmailTemplates/ContactEnquiry.html")))
            {
                body = reader.ReadToEnd();
            }
            body = body.Replace("{Name}", model.Name);
            body = body.Replace("{Date}", DateTime.Now.ToShortDateString());
            body = body.Replace("{Email}", model.Email);
            body = body.Replace("{Mobile}", model.Mobile);
            body = body.Replace("{Message}", model.Message);
            body = body.Replace("{PinCode}", model.Pincode);

            EmailServiceDTO email = new EmailServiceDTO();

            email.ToEmail      = model.Email;
            email.Status       = (int)AspectEnums.EmailStatus.Pending;
            email.Body         = body;
            email.ToName       = model.Name;
            email.Priority     = 2;
            email.IsAttachment = false;
            ActivityLog.SetLog("[FINISH][PrepareAndSendContactEmail]", LogLoc.INFO);
            return(SendEmail(email));
        }
Пример #3
0
        public JsonResponse <int> ContactUsEnquiry(ContactEnquiryDTO enquiry)
        {
            JsonResponse <int> response = new JsonResponse <int>();

            ActivityLog.SetLog("[START][ContactUsEnquiry]", LogLoc.INFO);
            try
            {
                enquiry.Status        = (int)AspectEnums.EnquiryStatus.Received;
                response.SingleResult = NotificationBusinessInstance.SubmitContactEnquiry(enquiry);
                response.IsSuccess    = response.SingleResult > 0? true: false;

                if (response.IsSuccess)
                {
                    EmailHelper helper = new EmailHelper();
                    helper.PrepareAndSendContactEmail(enquiry);
                    response.StatusCode = "200";
                    response.Message    = "Your enquiry is successfully posted.  We will send you email shortly.";
                }
            }
            catch (Exception ex)
            {
                ActivityLog.SetLog("Message: " + ex.Message + "Inner Ex: " + ex.InnerException, LogLoc.ERROR);
                response.IsSuccess  = false;
                response.StatusCode = "500";
                response.Message    = "Your enquiry is failed.";
            }
            ActivityLog.SetLog("[END][ContactUsEnquiry]", LogLoc.INFO);
            return(response);
        }