コード例 #1
0
        public ActionResult Edit(String name, HttpPostedFileBase file)
        {
            League league = null;

            if (ModelState.IsValid)
            {
                try
                {
                    if (file.ContentLength > 0)
                    {
                        var    fileName = Path.GetFileName(file.FileName);
                        String path     = Path.Combine(Server.MapPath("~/images"), fileName);
                        file.SaveAs(path);

                        String pathInXML = "/images/" + file.FileName;

                        league = new League(name, pathInXML);

                        _repository.EditLeague(league);
                        return(RedirectToAction("Index"));
                    }
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("", "Error insert new league: " + e.Message);
                }
            }
            return(View(league));
        }
コード例 #2
0
 public void EditLeague(League league)
 {
     _leaguerepo.EditLeague(league);
 }