Exemplo n.º 1
0
        public ActionResult EditTestimonial(Testimonial testimonial, HttpPostedFileBase image)
        {
            if (ModelState.IsValid)
            {
                if (image == null)
                {
                    testimonialrepository.SaveSimpleTestimonial(testimonial);
                    TempData["message"] = string.Format("{0} has been saved", testimonial.TestimonialUser);
                }
                else
                {
                    testimonial.TestimonialMimeType  = image.ContentType;
                    testimonial.TestimonialImageData = new byte[image.ContentLength];
                    image.InputStream.Read(testimonial.TestimonialImageData, 0, image.ContentLength);

                    testimonialrepository.SaveTestimonial(testimonial);
                    TempData["message"] = string.Format("{0} has been saved", testimonial.TestimonialUser);
                }
                return(RedirectToAction("Testimonial"));
            }
            else
            {
                return(View(testimonial));
            }
        }