Files
PocketSharp/PocketSharp/Models/Parameters/ActionParameter.cs
T

87 lines
1.8 KiB
C#
Raw Normal View History

2013-06-27 00:57:58 +02:00
using System;
2013-06-24 19:55:16 +02:00
using System.Collections.Generic;
namespace PocketSharp.Models
{
/// <summary>
/// All parameters which can be passed for a modify action
/// </summary>
2013-06-27 00:26:47 +02:00
public class ActionParameter
2013-06-24 19:55:16 +02:00
{
/// <summary>
/// Gets or sets the action.
/// </summary>
/// <value>
/// The action.
/// </value>
2013-06-24 19:55:16 +02:00
public string Action { get; set; }
/// <summary>
/// Gets or sets the ID.
/// </summary>
/// <value>
/// The ID.
/// </value>
2013-06-24 19:55:16 +02:00
public int ID { get; set; }
/// <summary>
/// Gets or sets the time.
/// </summary>
/// <value>
/// The time.
/// </value>
2013-06-24 19:55:16 +02:00
public DateTime? Time { get; set; }
2013-06-26 23:49:11 +02:00
// specific params
/// <summary>
/// Gets or sets the tags.
/// </summary>
/// <value>
/// The tags.
/// </value>
2013-06-26 23:49:11 +02:00
public string[] Tags { get; set; }
/// <summary>
/// Gets or sets the old tag.
/// </summary>
/// <value>
/// The old tag.
/// </value>
2013-06-26 23:49:11 +02:00
public string OldTag { get; set; }
/// <summary>
/// Gets or sets the new tag.
/// </summary>
/// <value>
/// The new tag.
/// </value>
2013-06-26 23:49:11 +02:00
public string NewTag { get; set; }
2013-06-24 19:55:16 +02:00
/// <summary>
/// Converts this instance to a parameter list.
/// </summary>
/// <returns></returns>
2013-06-24 19:55:16 +02:00
public object Convert()
{
Dictionary<string, object> parameters = new Dictionary<string, object>
{
2013-06-26 23:49:11 +02:00
{ "item_id", ID },
2013-06-24 19:55:16 +02:00
{ "action", Action }
};
2013-06-27 00:26:47 +02:00
if (Time != null)
parameters.Add("time", Utilities.GetUnixTimestamp(Time));
2013-06-26 23:49:11 +02:00
if (Tags != null)
parameters.Add("tags", String.Join(",", Tags));
if (OldTag != null)
parameters.Add("old_tag", OldTag);
if (NewTag != null)
parameters.Add("new_tag", NewTag);
2013-06-24 19:55:16 +02:00
return parameters;
}
}
}