Пример #1
0
    public static bool del(CarEngine.Part type, int status, int amount)
    {
        bool   success = false;
        string key     = PartData.getKey(type, status);

        PartData part = PartData.getOne(x => x.key == key);

        if (part != null)
        {
            part.quantity -= amount;
            part.save();
            success = true;
        }

        return(success);
    }
Пример #2
0
    public static bool add(CarEngine.Part type, int status, int amount)
    {
        bool   success = false;
        string key     = PartData.getKey(type, status);

        PartData part = PartData.getOne(x => x.key == key);

        if (part != null)
        {
            part.quantity += amount;
            part.save();
            success = true;
        }
        else
        {
            PartData item = new PartData {
                part     = (int)type,
                quantity = amount,
                status   = status
            };
            success = item.create();
        }
        return(success);
    }