Ejemplo n.º 1
0
        /// <summary>
        /// add an item
        /// </summary>
        /// <returns></returns>
        public static string AddItem(CallMetricsTable metrics)
        {
            try
            {
                ApiContext ctx = GetContext();
                ctx.EnableMetrics = true;
                ctx.CallMetricsTable = metrics;
                AddItemCall call = new AddItemCall(ctx);
                call.Site = SiteCodeType.US;
                call.Item=ItemHelper.BuildItem();
                call.Execute();

                return CheckForErrors("AddItem", call) ?
                call.ApiResponse.ItemID : null;
            }
            catch (Exception e)
            {
                ShowException("AddItem()", e);
                return null;
            }
        }
Ejemplo n.º 2
0
		/// <summary>
		/// revise an item
		/// </summary>
		/// <param name="itemId"></param>
		/// <param name="metrics"></param>
		public static void ReviseItem(ItemType item, CallMetricsTable metrics) 
		{
			Debug.Assert(item != null);
			Debug.Assert(item.ItemID != null);
			Debug.Assert(item.ItemID.Length > 0);
			
			try
			{
				ApiContext ctx = GetContext();
				ctx.EnableMetrics = true;
				ctx.CallMetricsTable = metrics;
				ReviseItemCall call = new ReviseItemCall(ctx);
				call.Site = SiteCodeType.US;
				ItemType itemToBeRevised = new ItemType();
				itemToBeRevised.ItemID = item.ItemID;
				call.Item=itemToBeRevised;
				itemToBeRevised.Description="Item has been modified!";

				call.Execute();

			}
			catch (Exception e) 
			{
				if(item==null)
				{
					ShowException("ReviseItem(null)", e);
				}
				else
				{
					ShowException("ReviseItem(" + item.ItemID + ")", e);
				}
			}
		}
Ejemplo n.º 3
0
		/// <summary>
		/// get an item
		/// </summary>
		/// <param name="itemId"></param>
		/// <param name="metrics"></param>
		/// <returns></returns>
		public static ItemType GetItem(string itemId, CallMetricsTable metrics) 
		{
			Debug.Assert(itemId != null);
			Debug.Assert(itemId.Length > 0);

			try 
			{
				ApiContext ctx = GetContext();
				ctx.EnableMetrics = true;
				ctx.CallMetricsTable = metrics;
				GetItemCall call = new GetItemCall(ctx);
				call.Site = SiteCodeType.US;

				ItemType item = call.GetItem(itemId);
				return CheckForErrors("GetItem", call) ? item : null;
			}
			catch (Exception e) {
				ShowException("GetItem(" + itemId + ")", e);
				return null;
			}
		}