Exemplo n.º 1
0
        public ActionResult AddMovie(Movie movieInn, HttpPostedFileBase file)
        {
            StringBuilder ImagePath = new StringBuilder("jpg/");

            if (ModelState.IsValid)
            {
                try
                {
                    file.SaveAs(HttpContext.Server.MapPath(@"~\Content\jpg\") + file.FileName);

                    ImagePath.Append(file.FileName);

                    var success = _db.AddMovie(movieInn, ImagePath.ToString());

                    if (success)
                    {
                        return(RedirectToAction("Dashbord"));
                    }
                }
                catch (Exception e)
                {
                    var error = new ErrorFiler();
                    error.WriteError(e.GetType().FullName, "Failure in file upload");
                }
            }

            return(View());
        }