using System;
using Microsoft.Xrm.Sdk;
using Microsoft.Crm.Sdk.Messages; /// <summary>
/// 产品
/// </summary>
public class ProductHelper
{
public static readonly string entityName = "product";
public Guid productId = Guid.Empty;
public IOrganizationService service; /// <summary>
/// 创建产品
/// </summary>
public void Create()
{
Entity en = new Entity() { LogicalName = entityName };
en["name"] = "产品测试";
productId = service.Create(en);
} /// <summary>
/// 向配套件中添加产品。配套件是包含一个或多个产品的产品目录项
/// </summary>
/// <param name="kitId">配套件id</param>
public void AddProductToKit(Guid kitId)
{
AddProductToKitRequest request = new AddProductToKitRequest();
request.KitId = kitId;
request.ProductId = productId;
AddProductToKitResponse response = (AddProductToKitResponse)service.Execute(request);
} /// <summary>
/// 将配套件转换为产品
/// </summary>
/// <param name="kitId">配套件id</param>
public void ConvertKitToProduct(Guid kitId)
{
ConvertKitToProductRequest request = new ConvertKitToProductRequest();
request.KitId = kitId;
ConvertKitToProductResponse response = (ConvertKitToProductResponse)service.Execute(request);
} /// <summary>
/// 将产品转换为配套件
/// </summary>
public void ConvertProductToKit()
{
ConvertProductToKitRequest request = new ConvertProductToKitRequest();
request.ProductId = productId;
ConvertProductToKitResponse response = (ConvertProductToKitResponse)service.Execute(request);
} /// <summary>
/// 从配套件中删除产品
/// </summary>
/// <param name="kitId">配套件id</param>
public void RemoveProductFromKit(Guid kitId)
{
RemoveProductFromKitRequest request = new RemoveProductFromKitRequest();
request.KitId = kitId;
request.ProductId = productId;
RemoveProductFromKitResponse response = (RemoveProductFromKitResponse)service.Execute(request);
} /// <summary> ///
/// 删除产品 ///
/// </summary>
public void Delete() { service.Delete(entityName, productId); }
}

Product Helper的更多相关文章

  1. 实现Magento多文件上传代码功能开发

    在Magento中上传单个文件很简单,可以直接在继承的Mage_Adminhtml_Block_Widget_Form类中直接添加如下组件Field:  对于图片:   $fieldset->a ...

  2. 12月16日 增加一个购物车内product数量的功能, 自定义method,在helper中定义,计算代码Refactor到Model中。

    仿照Rails实战:购物网站 教材:5-6 step5:计算总价,做出在nav上显示购物车内product的数量. 遇到的❌: 1. <% sum = 0 %> <% current ...

  3. ASP.NET MVC 3 and the @helper syntax within Razor

    Friday, May 13, 2011 ASP.NET MVC 3 supports a new view-engine option called “Razor” (in addition to ...

  4. [C#] 简单的 Helper 封装 -- RegularExpressionHelper

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  5. handlebars自定义helper的写法

    handlebars相对来讲算一个轻量级.高性能的模板引擎,因其简单.直观.不污染HTML的特性,我个人特别喜欢.另一方面,handlebars作为一个logicless的模板,不支持特别复杂的表达式 ...

  6. Encountered an unexpected error when attempting to resolve tag helper directive '@addTagHelper' with value '"*, Microsoft.AspNet.Mvc.TagHelpers"'

    project.json 配置: { "version": "1.0.0-*", "compilationOptions": { " ...

  7. VS2015突然报错————Encountered an unexpected error when attempting to resolve tag helper directive '@addTagHelper' with value 'Microsoft.AspNet.Mvc.Razor.TagHelpers.UrlResolutionTagHelper

    Encountered an unexpected error when attempting to resolve tag helper directive '@addTagHelper' with ...

  8. uva 11059 maximum product(水题)——yhx

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAB1QAAAMcCAIAAABo0QCJAAAgAElEQVR4nOydW7msuhKF2wIasIAHJK

  9. [LeetCode] Product of Array Except Self 除本身之外的数组之积

    Given an array of n integers where n > 1, nums, return an array output such that output[i] is equ ...

随机推荐

  1. SpringMVC学习(一)——概念、流程图、源码简析

    学习资料:开涛的<跟我学SpringMVC.pdf> 众所周知,springMVC是比较常用的web框架,通常整合spring使用.这里抛开spring,单纯的对springMVC做一下总 ...

  2. 音乐播放插件Aplayer+WebAPI的使用【附下载】

    本次介绍的是音乐播放器APlayer结合WebAPI的使用,先给各位看下效果:   上面就是APlayer的效果,然后这插件的地址是 https://github.com/DIYgod/APlayer ...

  3. GCC the GNU

         GCC简单使用 -v/-v/--version 查看gcc版本号 python@ubuntu:~$ gcc -v -I 指定头文件目录,注意-I和之间没有空格 1 #include<s ...

  4. pc端配置详细 2017级机械设计新生 史浩然

    品牌名称:SAMSUNG/三星         证书状态:有效        申请人名称:苏州三星电子电脑有限公司     型号:940X3K-K01       操作系统:window8.1 产品名 ...

  5. 修改virtual box中ubuntu lubuntu 的分辨率

    Step1 先用xrandr命令查看能够支持的分辨率 Step2 xrandr --output VGA-1 --size 1280x800 Step3 重启电脑

  6. 【转】[C++]实现委托模型

    原文地址:http://www.cnblogs.com/zplutor/archive/2011/09/17/2179756.html 我对.Net的委托模型印象很深刻,使用委托,可以快速实现观察者模 ...

  7. .NET事务

    概述 事务ACID特性 事务将一系列的工作视为一个工作单元,它具有 ACID 特性: A:Atomicity 不可分性也就是说事务中有多项工作,如果有一项工作失败了,整个事务就算失败了. C:Cons ...

  8. Yii2.0随笔 路由

    1.去掉index.php,按照pathinfo模式访问 例:http://***.com/控制器/方法 (1)把web服务器的网站目录指向所在模块的web目录 (2)在main.php的 'comp ...

  9. SQL 关联两个表的视图总结

    视图就是一条select查询语句,是一张虚拟表. table a  , table b  以表a基表(a LEFT  JOIN b) 1.1 当update view时 更新view中表b字段并且表b ...

  10. [19/04/12-星期五] 多线程_任务定时调度(Timer、Timetask和QUARTZ)

    一.Timer和Timetask 通过Timer和Timetask,我们可以实现定时启动某个线程. java.util.Timer 在这种实现方式中,Timer类作用是类似闹钟的功能,也就是定时或者每 ...