Esempio n. 1
0
 public EnquiryNoteModel(EnquiryNote enquiryNote)
 {
     _enquiryNote = enquiryNote;
 }
Esempio n. 2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the EnquiryNotes EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToEnquiryNotes(EnquiryNote enquiryNote)
 {
     base.AddObject("EnquiryNotes", enquiryNote);
 }
Esempio n. 3
0
 /// <summary>
 /// Create a new EnquiryNote object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="enquiryID">Initial value of the EnquiryID property.</param>
 /// <param name="date">Initial value of the Date property.</param>
 /// <param name="note">Initial value of the Note property.</param>
 /// <param name="userID">Initial value of the UserID property.</param>
 public static EnquiryNote CreateEnquiryNote(global::System.Guid id, global::System.Guid enquiryID, global::System.DateTime date, global::System.String note, global::System.Guid userID)
 {
     EnquiryNote enquiryNote = new EnquiryNote();
     enquiryNote.ID = id;
     enquiryNote.EnquiryID = enquiryID;
     enquiryNote.Date = date;
     enquiryNote.Note = note;
     enquiryNote.UserID = userID;
     return enquiryNote;
 }
Esempio n. 4
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();
        }