Exemple #1
0
 /// <summary>
 /// Update
 /// </summary>
 /// <param name="id"></param>
 /// <param name="Product"></param>
 /// <returns></returns>
 public HttpResponseMessage Put(int id, ProductDTO Product)
 {
     Product.ProductId = id;
     if (!ProductManage.Update(Product))
     {
         throw new HttpResponseException(HttpStatusCode.NotFound);
     }
     HttpContext.Current.Cache.Remove(keyPrefixProductId + id);
     HttpContext.Current.Cache.Remove(keyAllProduct);
     HttpResponse.RemoveOutputCacheItem("/Home/Index");
     return(Request.CreateResponse(HttpStatusCode.OK, new { success = true, message = "Has updated." }));
 }
Exemple #2
0
 /// <summary>
 /// 添加或编辑
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static ProductInfo Create(ProductInfo model)
 {
     if (model.Id == 0)
     {
         model.Id = ProductManage.Insert(model);
     }
     else
     {
         ProductManage.Update(model);
     }
     return(model);
 }
Exemple #3
0
    void btnSave_Click(object sender, EventArgs e)
    {
        int _selectCategoryId = Convert.ToInt32(this.ddlcategoryList.SelectedValue);

        if (_selectCategoryId == 0)
        {
            this.ltErrorMsg.Text = "请选择所属分类";
            return;
        }

        productInfo            = new ProductInfo();
        productInfo.CategoryId = _selectCategoryId;
        productInfo.Content    = txtContent.Text;
        productInfo.Title      = txtTitle.Text;

        ProductManage.Update(productInfo);
        string js = string.Format("alert('保存成功!');window.location.href='productlist.aspx?categoryId={0}';", _selectCategoryId);

        Page.ClientScript.RegisterStartupScript(this.GetType(), "SaveSuccess", js, true);
    }