コード例 #1
0
        public ActionResult Create([Bind(Exclude = "Id")] FlowersShop flower)
        {
            if (ModelState.IsValid)
            {
                string rootPath = Server.MapPath("~/");
                string fileName = System.IO.Path.GetFileName(flower.ImagePath);

                flower.ImagePath = "images/" + fileName;
                _context.FlowersShops.InsertOnSubmit(flower);
                _context.SubmitChanges();
            }
            return(Json(flower, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public ActionResult Update(FlowersShop flower)
        {
            if (ModelState.IsValid)
            {
                string rootPath = Server.MapPath("~/");
                string fileName = System.IO.Path.GetFileName(flower.ImagePath);
                flower.ImagePath = "images/" + fileName;

                FlowersShop fs = (from p in _context.FlowersShops
                                  where p.Id == flower.Id
                                  select p).SingleOrDefault();

                fs.FlowersName = flower.FlowersName;
                fs.ImagePath   = flower.ImagePath;
                fs.TagContent  = flower.TagContent;
                fs.TypeColumn  = flower.TypeColumn;
                _context.SubmitChanges();
            }
            return(Json(flower, JsonRequestBehavior.AllowGet));
        }