当前位置: 首页>>代码示例>>C#>>正文


C# ProductRepository.Delete方法代码示例

本文整理汇总了C#中ProductRepository.Delete方法的典型用法代码示例。如果您正苦于以下问题:C# ProductRepository.Delete方法的具体用法?C# ProductRepository.Delete怎么用?C# ProductRepository.Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProductRepository的用法示例。


在下文中一共展示了ProductRepository.Delete方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Delete

 public ActionResult Delete(Guid Id)
 {
     ProductRepository<Product> dao = new ProductRepository<Product>();
     Product produto = dao.ListarPorId(Id);
     dao.Delete(produto);
     return RedirectToAction("index", "Product");
 }
开发者ID:MarceloNascimento,项目名称:SICPROD,代码行数:7,代码来源:ProductController.cs

示例2: ShouldDeleteAProduct

 public void ShouldDeleteAProduct()
 {
     var productRepository = new ProductRepository(@"Repository\Products.txt", "Product");
     productRepository.Delete(2);
     Assert.AreEqual(2,productRepository.GetAll().Count());
 }
开发者ID:florentinac,项目名称:repository,代码行数:6,代码来源:ProductRepository.Tests.cs

示例3: Delete

 public void Delete(Guid id)
 {
     ProductRepository p = new ProductRepository(_sqlConnectionString);
     p.Delete(id);
 }
开发者ID:MarneeDear,项目名称:Terminal-Management-Applications,代码行数:5,代码来源:ProductsController.cs

示例4: Delete

        public ActionResult Delete(Product product)
        {
            try
            {
                using (var productRep = new ProductRepository())
                {
                    productRep.Delete(product);
                }

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
开发者ID:fabiopsouza,项目名称:Learning.AspNetMVC,代码行数:16,代码来源:ProductController.cs

示例5: ProcessRequest

        public void ProcessRequest(HttpContext context)
        {
            String output;

            try
            {
                var formCollection = context.Request.Form;

                Product prod = new Product();
                String prodID = formCollection["id"];

                if (prodID.Equals("_empty"))
                {
                    prod.ProductID = 0;
                }
                else
                {
                    prod.ProductID = Convert.ToInt32(prodID);
                }

                var operation = formCollection["oper"];

                using (ProductRepository repo = new ProductRepository())
                {

                    if (operation.Equals("add") || operation.Equals("edit"))
                    {

                        prod.ProductName = formCollection["ProductName"];
                        prod.SupplierID = Convert.ToInt32(formCollection["SupplierID"]);
                        prod.UnitPrice = Convert.ToDecimal(formCollection["UnitPrice"]);
                        prod.UnitsInStock = Convert.ToSByte(formCollection["UnitsInStock"]);
                        prod.UnitsOnOrder = Convert.ToSByte(formCollection["UnitsOnOrder"]);

                        if (logger.IsDebugEnabled)
                        {
                            logger.Debug("Received request for operation: " + operation + " for Product ID: " + prod.ProductID);

                            logger.Debug(prod);
                        }

                        repo.SaveOrUpdate(prod);
                    }
                    else if (operation.Equals("del"))
                    {

                        if (logger.IsDebugEnabled)
                        {
                            logger.Debug("Received request to delete Product ID: " + prod.ProductID);

                            logger.Debug(prod);
                        }
                        repo.Delete(prod);

                    }

                }

                output = "Operation successful.";
            }
            catch (Exception ex)
            {
                if (logger.IsDebugEnabled)
                {
                    output = ex.Message;
                }
                else
                {
                    output = "Oops! We encountered an error while performing the requested operation!";

                }

                logger.Error(ex);
                throw new Exception(output);
            }

            context.Response.ContentType = "text/plain";
            context.Response.Write(output);
        }
开发者ID:bbcCorp,项目名称:Linq2Sql,代码行数:79,代码来源:UpdateProduct.ashx.cs


注:本文中的ProductRepository.Delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。