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; } }