Exemple #1
0
    public static string DeleteItem(int itemId)
    {
        Dictionary <string, string> result = new Dictionary <string, string>()
        {
            { "id", itemId.ToString() }
            , { "exists", "" }
            , { "deleted", "" }
            , { "error", "" }
        };
        bool   exists = false, deleted = false;
        string errorMsg = string.Empty;

        try
        {
            //delete
            if (itemId == 0)
            {
                errorMsg = "You must specify an item to delete.";
            }
            else
            {
                deleted = WorkloadItem.WorkItem_TestItem_Delete(itemId, out exists, out errorMsg);
            }
        }
        catch (Exception ex)
        {
            LogUtility.LogException(ex);
            deleted  = false;
            errorMsg = ex.Message;
        }

        result["exists"]  = exists.ToString();
        result["deleted"] = deleted.ToString();
        result["error"]   = errorMsg;

        return(JsonConvert.SerializeObject(result, Formatting.None));
    }