public ActionResult Edit(tb_Prodect model, HttpPostedFileWrapper Icon, HttpPostedFileWrapper Conver) { tb_Prodect pronew = Entities.tb_Prodect.FirstOrDefault(t => t.Id == model.Id); string pathFileName = string.Empty; if (Icon?.ContentLength > 0) { pathFileName = $"{basePath}{CommonHelper.GetNowLangTime()}1{Path.GetExtension(Icon.FileName)}"; Icon.SaveAs(Server.MapPath("~" + pathFileName)); pronew.Icon = pathFileName; } if (Conver?.ContentLength > 0) { pathFileName = $"{basePath}{CommonHelper.GetNowLangTime()}2{Path.GetExtension(Conver.FileName)}"; Conver.SaveAs(Server.MapPath("~" + pathFileName)); pronew.Conver = pathFileName; } pronew.Title = model.Title; pronew.Content = model.Content; pronew.LanguageId = Language.Id; pronew.NormsId = model.NormsId; Entities.SaveChanges(); return(RedirectToAction("List")); }
/// <summary> /// 产品编辑 /// </summary> /// <returns></returns> public ActionResult Edit(int id) { ViewBag.Norms = Entities.tb_Norms.ToList(); ViewBag.Languages = Entities.tb_Language.ToList(); tb_Prodect model = Entities.tb_Prodect.FirstOrDefault(t => t.Id == id); return(View(model)); }
public ActionResult Delete(int id) { tb_Prodect pro = Entities.tb_Prodect.FirstOrDefault(t => t.Id == id); Entities.tb_Prodect.Remove(pro); Entities.SaveChanges(); return(RedirectToAction("List")); }
public ActionResult Add(tb_Prodect model, HttpPostedFileWrapper Icon, HttpPostedFileWrapper Conver) { string pathFileName = string.Empty; pathFileName = basePath + CommonHelper.GetNowLangTime() + "1" + Path.GetExtension(Icon.FileName); Icon.SaveAs(Server.MapPath("~" + pathFileName)); model.Icon = pathFileName; pathFileName = basePath + CommonHelper.GetNowLangTime() + "2" + Path.GetExtension(Conver.FileName); Conver.SaveAs(Server.MapPath("~" + pathFileName)); model.Conver = pathFileName; model.LanguageId = Language.Id; Entities.tb_Prodect.Add(model); Entities.SaveChanges(); return(RedirectToAction("List")); }