partial void DeleteProduct(Product instance);
partial void UpdateProduct(Product instance);
partial void InsertProduct(Product instance);
private void detach_Products(Product entity) { this.SendPropertyChanging(); entity.Supplier = null; }
private void attach_Products(Product entity) { this.SendPropertyChanging(); entity.Supplier = this; }
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); }