Exemplo n.º 1
0
    public static string DeleteItem(int itemId)//, string item)
    {
        Dictionary <string, string> result = new Dictionary <string, string>()
        {
            { "id", itemId.ToString() }
            , { "exists", "" }
            , { "hasDependencies", "" }
            , { "deleted", "" }
            , { "archived", "" }
            , { "error", "" }
        };
        bool   exists = false, deleted = false, archived = false; //hasDependencies = false, deleted = false, archived = false;
        string errorMsg = string.Empty;

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

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

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