コード例 #1
0
        public ActionResult Create(ArticleModel model, HttpPostedFileBase file)
        {
            if (ModelState.IsValid && file != null)
            {
                file.SaveAs(HttpContext.Server.MapPath(Links.UploadRoute) + file.FileName);
                model.Picture = Links.Uploads + file.FileName;

                _modelRepository.CreateArticleFromModel(model);
                return(RedirectToAction("Index", "Home"));
            }

            ModelState.AddModelError(ErrorMessages.Error, ErrorMessages.UploadError);
            return(View(model));
        }