/// <summary> /// 删除数据 /// </summary> /// <param name="theData">删除的数据</param> public ActionResult DeleteData(string ids) { _tagBusiness.Delete(ids.ToList <string>()); return(Success("删除成功!")); }
public virtual JsonResult Delete(TagViewModel key) { var res = _tagBusiness.Delete(key.Id); return(Json(res, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit([Bind(Include = "ProductId,Title,Description,Text,Visit,Price,ImageName,Sort")] Product product, List <int> selectedCategory, HttpPostedFileBase imageProduct, string tags) { if (ModelState.IsValid) { // Check Categories if (selectedCategory == null) { ViewBag.Category = true; ViewBag.SelectedCategory = selectedCategory; ViewBag.Tags = tags; ViewBag.Categories = _categoryBusiness.Get(); return(View(product)); } // Image if (imageProduct != null && imageProduct.IsImage()) { if (product.ImageName != "user123456789.png") { System.IO.File.Delete(Server.MapPath("/Content/Image/Product/" + product.ImageName)); System.IO.File.Delete(Server.MapPath("/Content/Image/Product/Thumbnail/" + product.ImageName)); } product.ImageName = Guid.NewGuid().ToString() + Path.GetExtension(imageProduct.FileName); imageProduct.SaveAs(Server.MapPath("/Content/Image/Product/" + product.ImageName)); ImageResizer img = new ImageResizer(); img.Resize(Server.MapPath("/Content/Image/Product/" + product.ImageName), Server.MapPath("/Content/Image/Product/Thumbnail/" + product.ImageName)); } _productBusiness.Update(product); _productBusiness.Save(); // Category _productCategoryBusiness.GetByProductId(product.ProductId).ForEach(p => _productCategoryBusiness.Delete(p)); foreach (var category in selectedCategory) { _productCategoryBusiness.Insert(new ProductCategory() { CategoryId = category, ProductId = product.ProductId }); } _productCategoryBusiness.Save(); // Tags _tagBusiness.GetByProductId(product.ProductId).ForEach(t => _tagBusiness.Delete(t.TagId)); if (!string.IsNullOrEmpty(tags)) { string[] tagsList = tags.Split(','); foreach (var tag in tagsList) { _tagBusiness.Insert(new Tag() { ProductId = product.ProductId, TagName = tag.Trim() }); } } _tagBusiness.Save(); return(RedirectToAction("Index")); } ViewBag.SelectedCategory = selectedCategory; ViewBag.Tags = tags; ViewBag.Categories = _categoryBusiness.Get(); return(View(product)); }