public PartialViewResult Index(ContactInputModel inputModel)
        {
            if (ModelState.IsValid)
            {
                var user = new Customer
                {
                    FullName = inputModel.FullName,
                    Email = inputModel.Email.ToLower(),
                    Telephone = inputModel.Telephone
                };

                var note = new Note
                {
                    Message = inputModel.Message
                };

                customerService.EnquiryRequest(user, note);

                return PartialView("SendMessage");
            }

            var viewModel = new ContactViewModel
            {
                FullName = inputModel.FullName,
                Email = inputModel.Email.ToLower(),
                Telephone = inputModel.Telephone,
                Message = inputModel.Message
            };

            return PartialView("Index", viewModel);
        }
Example #2
0
        public void SendEnquiryRequestMessage(IUser user, Note note)
        {
            var templateBody = TemplateBody(templateSettings.GetEnquiryRequest());

            var replacementKeyValues = new List<KeyValuePair<string, string>>
            {
                new KeyValuePair<string, string>("{{BaseUrl}}", templateSettings.GetBasePath()),
                new KeyValuePair<string, string>("{{FullName}}", user.FullName),
                new KeyValuePair<string, string>("{{Email}}", user.Email),
                new KeyValuePair<string, string>("{{Telephone}}", user.Telephone),
                new KeyValuePair<string, string>("{{Message}}", note.Message)
            };

            string body = templateManager.PopulateTemplate(templateBody, replacementKeyValues);

            Logger.Info("Sending Enquiry Response Message");

            string subject = string.Format("Enquiry Request from: {0}", user.Email);

            var toAndFromAddress = emailAddressSettings.GetInfoEmailAddress();

            if (emailer.TrySendMail(toAndFromAddress, toAndFromAddress, subject, body))
            {
                Logger.Info("Send succeeded");
            }
        }
Example #3
0
        public ActionResult AddNote(AddNoteViewModel inputModel)
        {
            var job = jobService.GetJob(inputModel.JobId);
            var note = new Note()
            {
                CreatedOn = DateTime.Now,
                Message = inputModel.Message,
            };

            jobService.AddNote(job, note, inputModel.SendToCustomer, inputModel.SendToWorker);
            jobService.SaveJob(job);

            return RedirectToAction("Job", new { id = job.Id });
        }
Example #4
0
        public void AddNote(Job job, Note note, bool noteToCustomer, bool noteToWorker)
        {
            AddNote(job, note);

            if (noteToCustomer && job.Customer != null)
            {
                notifier.SendJobNoteToWorker(job, note);
            }

            if (noteToWorker && job.Worker != null)
            {
                notifier.SendJobNoteToCustomer(job, note);
            }
        }
Example #5
0
        public void EnquiryResponse(Customer user, Note note)
        {
            var existingCustomer = customerRepository.FindBy(user.Email);

            if (existingCustomer != null)
            {
                existingCustomer.Notes.Add(note);
                customerRepository.Update(existingCustomer);
                user = existingCustomer;
            }
            else
            {
                user.Notes.Add(note);
                customerRepository.Add(user);
            }

            customerRepository.UnitOfWork.Commit();

            notifier.SendEnquiryResponseMessage(user, note);
        }
Example #6
0
        public void SendJobNoteToWorker(Job job, Note note)
        {
            string body = GetNoteBody(note.Message);

            Logger.Info("Sending Job Note To Worker");

            string subject = string.Format("Re: {0}", job.Reference);

            var toAddress = emailAddressSettings.CreateEmailAddress(job.Worker.Email, job.Worker.FullName);
            var fromAddress = emailAddressSettings.GetInfoEmailAddress();

            if (emailer.TrySendMail(toAddress, fromAddress, subject, body))
            {
                Logger.Info("Send succeeded");
            }
        }
Example #7
0
 public void AddNote(Job job, Note note)
 {
     job.Notes.Add(note);
     SaveJob(job);
 }