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)); }
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)); }