/// <summary>
 /// Create a new Enquiry object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="eventTypeID">Initial value of the EventTypeID property.</param>
 /// <param name="eventStatusID">Initial value of the EventStatusID property.</param>
 /// <param name="takenByID">Initial value of the TakenByID property.</param>
 /// <param name="assignedToID">Initial value of the AssignedToID property.</param>
 /// <param name="receivedMethodID">Initial value of the ReceivedMethodID property.</param>
 /// <param name="value">Initial value of the Value property.</param>
 /// <param name="enquiryStatusID">Initial value of the EnquiryStatusID property.</param>
 /// <param name="likelihood">Initial value of the Likelihood property.</param>
 /// <param name="creationDate">Initial value of the CreationDate property.</param>
 public static Enquiry CreateEnquiry(global::System.Guid id, global::System.Guid eventTypeID, global::System.Guid eventStatusID, global::System.Guid takenByID, global::System.Guid assignedToID, global::System.Guid receivedMethodID, global::System.Double value, global::System.Guid enquiryStatusID, global::System.Int32 likelihood, global::System.DateTime creationDate)
 {
     Enquiry enquiry = new Enquiry();
     enquiry.ID = id;
     enquiry.EventTypeID = eventTypeID;
     enquiry.EventStatusID = eventStatusID;
     enquiry.TakenByID = takenByID;
     enquiry.AssignedToID = assignedToID;
     enquiry.ReceivedMethodID = receivedMethodID;
     enquiry.Value = value;
     enquiry.EnquiryStatusID = enquiryStatusID;
     enquiry.Likelihood = likelihood;
     enquiry.CreationDate = creationDate;
     return enquiry;
 }
Exemple #2
0
        protected async void OnClick(object sender, EventArgs e)
        {
            if (!Page.IsValid) return;

            if (Session["CheckRefresh"].ToString() == ViewState["CheckRefresh"].ToString())
            {
                Session["CheckRefresh"] = Server.UrlDecode(DateTime.Now.ToString());
            }
            else
            {
                ClearAll();
                return;
            }

            DefaultSettingsForEnquiry defaultSettings =
                (await _webEnquiryDataUnit.DefaultSettingsForEnquiriesRepository.GetAllAsync()).First();

            var user = (await _webEnquiryDataUnit.UsersRepository.GetUsersAsync(x => x.ID == defaultSettings.UserID)).FirstOrDefault();

            var emailSettings = (await _webEnquiryDataUnit.EmailSettingsRepository.GetAllAsync()).First();

            var receivedMethods =
                new List<EnquiryReceiveMethod>(await _webEnquiryDataUnit.EnquiryReceiveMethodsRepository.GetAllAsync());
            var eventStatuses = new List<EventStatus>(await _webEnquiryDataUnit.EventStatusesRepository.GetAllAsync());

            var places = String.IsNullOrEmpty(txtNum.Text) ? 0 : Convert.ToInt32(txtNum.Text);
            var name = String.IsNullOrEmpty(txtName.Text) ? "Web Enquiry" : txtName.Text;
            DateTime? date;
            if (!String.IsNullOrEmpty(txtDate.Text))
                date = DateTime.ParseExact(txtDate.Text, "dd/MM/yyyy", CultureInfo.CurrentCulture);
            else
            {
                date = null;
            }

            var contact = new Contact()
            {
                ID = Guid.NewGuid(),
                FirstName = txtFirstName.Text,
                LastName = txtLastName.Text,
                Phone1 = txtMobilePhone.Text,
                Email = txtEmail.Text
            };
            _webEnquiryDataUnit.ContactsRepository.Add(contact);

            var enquiry = new Enquiry()
            {
                ID = Guid.NewGuid(),
                Date = date,
                Name = name,
                EventTypeID = Guid.Parse(EventTypesDropDown.SelectedValue),
                EventStatusID = eventStatuses.First(x => x.Name.Equals("Enquiry")).ID,
                Places = places,
                ContactID = contact.ID,
                EnquiryStatusID = defaultSettings.EnquiryStatusID,
                AssignedToID = defaultSettings.UserID,
                ReceivedMethodID = receivedMethods.First(x => x.ReceiveMethod == "web site").ID,
                TakenByID = defaultSettings.UserID,
                CreationDate = DateTime.Now
            };
            _webEnquiryDataUnit.EnquiriesRepository.Add(enquiry);

            if (!String.IsNullOrEmpty(txtEventDetails.Text))
            {
                var note = new EnquiryNote()
                {
                    ID = Guid.NewGuid(),
                    EnquiryID = enquiry.ID,
                    Note = txtEventDetails.Text,
                    Date = DateTime.Now,
                    UserID = defaultSettings.UserID,
                };

                _webEnquiryDataUnit.EnquiryNotesRepository.Add(note);
            }

            var update = new EnquiryUpdate()
            {
                ID = Guid.NewGuid(),
                EnquiryID = enquiry.ID,
                Date = DateTime.Now,
                UserID = defaultSettings.UserID,
                Message = string.Format("Enquiry {0} was created", enquiry.Name)
            };

            _webEnquiryDataUnit.EnquiryUpdatesRepository.Add(update);

            _webEnquiryDataUnit.SaveChanges();

            Alert("Enquiry was successfully sent", Page);

            try
            {
                using (var smtpClient = new SmtpClient(emailSettings.Server))
                {
                    smtpClient.Port = 587;
                    smtpClient.EnableSsl = emailSettings.EnableSSL;
                    smtpClient.UseDefaultCredentials = false;
                    smtpClient.Credentials = new NetworkCredential(emailSettings.Username, emailSettings.Password);

                    using (var message = new MailMessage())
                    {
                        message.From = new MailAddress(defaultSettings.FromAddress);
                        message.IsBodyHtml = true;
                        message.Subject = "Web Enquiry";
                        message.SubjectEncoding = Encoding.UTF8;
                        message.Body = "Enquiry " + enquiry.Name + " has been received.";
                        message.BodyEncoding = Encoding.UTF8;
                        message.To.Add(user.EmailAddress);

                        smtpClient.Send(message);

                    }
                }
            }
            catch (SmtpException)
            {
                Alert("Couldn't send email", Page);
            }
           
            ClearAll();
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Enquiries EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToEnquiries(Enquiry enquiry)
 {
     base.AddObject("Enquiries", enquiry);
 }
Exemple #4
0
        private void ProposePrimaryContact(Enquiry @enquiry)
        {
            if (@enquiry.Contact != null)
            {
                bool? dialogResult = null;
                string confirmText = string.Format("Do you want to choise {0} {1} as primary contact?", @enquiry.Contact.FirstName, @enquiry.Contact.LastName);

                RadWindow.Confirm(new DialogParameters()
                {
                    Owner = Application.Current.MainWindow,
                    Content = confirmText,
                    Closed = (sender, args) => { dialogResult = args.DialogResult; }
                });

                if (dialogResult == true)
                {
                    _enquiry.PrimaryContact = new ContactModel(@enquiry.Contact);
                    //_enquiry.Enquiry.Contact = @enquiry.Contact;   //Primary Contact issue
                }

            }
        }