Пример #1
0
        protected void _submitButton_Click(object sender, EventArgs e)
        {
            ITestimonialRepository testimonialRepository = new TestimonialRepository();
            var testimonial = new Testimonial
            {
                CustomerId      = CustomerId,
                IsAccepted      = null,
                Rank            = null,
                ReviewedBy      = null,
                ReviewedOn      = null,
                TestimonialText = _testimonialText.Text
            };

            testimonial = testimonialRepository.SaveTestimonial(testimonial);

            _divMessage.Style.Add(HtmlTextWriterStyle.Display, "block");
            if (testimonial.Id > 0)
            {
                _messageControl.ShowSuccessMessage("Testimonial submitted successfully for review.");
                _testimonialText.Text = string.Empty;
            }
            else
            {
                _messageControl.ShowErrorMessage("Testimonial has not been submitted, Please try again.");
            }
        }
Пример #2
0
        protected void _uploadVedioButton_Click(object sender, EventArgs e)
        {
            ITestimonialRepository testimonialRepository = new TestimonialRepository();

            var testimonial = new Testimonial
            {
                CustomerId      = CustomerId,
                IsAccepted      = null,
                Rank            = null,
                ReviewedBy      = null,
                ReviewedOn      = null,
                TestimonialText = string.Empty
            };

            // upload vedio
            string savePathPhysical = _physicalPath + "Testimonial";
            string savePathVirtual  = _virtualPath + "Testimonial";

            if (_uploadVedio.HasFile && _uploadVedio.FileName.Trim().Length > 0)
            {
                if (!Directory.Exists(savePathPhysical))
                {
                    Directory.CreateDirectory(savePathPhysical);
                }

                string fileExtension = new FileInfo(_uploadVedio.FileName).Extension;
                string fileName      = "Testimonial_" + CustomerId + "_" + DateTime.Now.ToFileTimeUtc() + "_" + _uploadVedio.FileName;

                _uploadVedio.SaveAs(savePathPhysical + "\\" + fileName);

                testimonial.TestimonialVideo = new File
                {
                    Path       = savePathVirtual + "/" + fileName,
                    FileSize   = (decimal)_uploadVedio.FileBytes.Length / 1024,
                    Type       = FileType.Video,
                    UploadedBy = GetCreatorOrganizationRoleUser(),
                    UploadedOn = DateTime.Now
                };
            }
            testimonial = testimonialRepository.SaveTestimonial(testimonial);

            _divMessage.Style.Add(HtmlTextWriterStyle.Display, "block");
            if (testimonial.Id > 0)
            {
                _messageControl.ShowSuccessMessage("Testimonial submitted successfully for review.");
            }
            else
            {
                _messageControl.ShowErrorMessage("Testimonial has not been submitted, Please try again.");
            }
        }
Пример #3
0
        private void SaveTestimonial()
        {
            ITestimonialRepository testimonialRepository = new TestimonialRepository();
            Testimonial            testimonial;

            // set testimonial and file id - update
            if (ViewState["TestimonialId"] != null)
            {
                testimonial = testimonialRepository.GetTestimonial(Convert.ToInt64(ViewState["TestimonialId"]));
                testimonial.TestimonialText = _testimonialText.Text;
            }
            else
            {
                testimonial = new Testimonial
                {
                    CustomerId      = CustomerId,
                    IsAccepted      = null,
                    Rank            = null,
                    ReviewedBy      = null,
                    ReviewedOn      = null,
                    TestimonialText = _testimonialText.Text
                };
            }
            // upload vedio
            string savePathPhysical = _physicalPath + "Testimonial";
            string savePathVirtual  = _virtualPath + "Testimonial";

            if (_uploadVedio.HasFile && _uploadVedio.FileName.Trim().Length > 0)
            {
                if (!Directory.Exists(savePathPhysical))
                {
                    Directory.CreateDirectory(savePathPhysical);
                }

                string fileExtension = new FileInfo(_uploadVedio.FileName).Extension;
                string fileName      = "Testimonial_" + CustomerId + "_" + DateTime.Now.ToFileTimeUtc() + "_" + _uploadVedio.FileName;

                _uploadVedio.SaveAs(savePathPhysical + "\\" + fileName);

                if (testimonial.TestimonialVideo != null && testimonial.TestimonialVideo.Id > 0)
                {
                    testimonial.TestimonialVideo = new File(testimonial.TestimonialVideo.Id)
                    {
                        Path       = savePathVirtual + "/" + fileName,
                        FileSize   = (decimal)_uploadVedio.FileBytes.Length / 1024,
                        Type       = FileType.Video,
                        UploadedBy = GetCreatorOrganizationRoleUser(),
                        UploadedOn = DateTime.Now
                    };
                }
                else
                {
                    testimonial.TestimonialVideo = new File
                    {
                        Path       = savePathVirtual + "/" + fileName,
                        FileSize   = (decimal)_uploadVedio.FileBytes.Length / 1024,
                        Type       = FileType.Video,
                        UploadedBy = GetCreatorOrganizationRoleUser(),
                        UploadedOn = DateTime.Now
                    };
                }
            }

            testimonial = testimonialRepository.SaveTestimonial(testimonial);

            _divMessage.Style.Add(HtmlTextWriterStyle.Display, "block");
            if (testimonial.Id > 0)
            {
                ViewState["TestimonialId"] = testimonial.Id;
                _messageControl.ShowSuccessMessage("Testimonial Submitted Successfully for Review.");
            }
            else
            {
                _messageControl.ShowErrorMessage("Testimonial has not been submitted, Please try again.");
                ViewState["TestimonialId"] = null;
            }
        }