Ejemplo n.º 1
0
        public ActionResult Create(Testimonial model)
        {
            try
            {
                UploadFile(HttpContext.Request, model);
                model.IsActive = false;
                _testimonialService.Add(model);
                _testimonialService.Save();

                //if (file.ContentLength > 0)
                //{
                //    var model = new Testimonial();

                //    string _FileName = Path.GetFileName(file.FileName);
                //    string _path = Path.Combine(Server.MapPath("~/GalleryPhotos"), _FileName);
                //    file.SaveAs(_path);
                //    model.ImageUrl = _path;

                //    _testimonialService.Add(model);
                //    _testimonialService.Save();
                //}
                //ViewBag.Message = "File Uploaded Successfully!!";

                return(View("ThankYou"));
            }
            catch (Exception ex)
            {
                ViewBag.Message = "File upload failed!!";
                return(View());
            }
        }