コード例 #1
0
        public ActionResult Create(WildCat wildcat)
        {
            if (ModelState.IsValid)
            {
                //try
                //{
                //    var fileName = Path.GetFileName(ImageUrl.FileName);
                //    //path = AppDomain.CurrentDomain.BaseDirectory + "Images\\" + fileName;
                //    path = HttpContext.Server.MapPath("~/Images/" + fileName);
                //    //path = Url.Content("~/UserContent/" + fileName);
                //    ImageUrl.SaveAs(path);
                //   // wildcat.ImageUrl = Url.Content("~/Images/" + fileName);
                //}
                //catch
                //{
                //    ViewBag.errorMessage = "Upload Fail";
                //}
                //wildcat.ImageUrl = Url.Content("~/UserContent/" + fileName);
                db.WildCats.Add(wildcat);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(wildcat);
        }
コード例 #2
0
        public ActionResult Edit(WildCat wildcat)
        {
            if (ModelState.IsValid)
            {

                db.Entry(wildcat).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(wildcat);
        }