Example #1
0
    public static void Add(EarningsStatsType type, Money amount)
    {
        DailyEarning Earning = DailyEarning.GetProperObject(type, DateTime.Now.Date);

        //Add & save
        Earning.SumAmount += amount;
        Earning.Save();
    }
Example #2
0
    public static DailyEarning GetProperObject(EarningsStatsType type, DateTime date)
    {
        DailyEarning Earning;

        var where = TableHelper.MakeDictionary("EarningsType", (int)type);
        where.Add("DateDay", date.Date);

        var result = TableHelper.SelectRows <DailyEarning>(where);

        if (result.Count == 0)
        {
            //Not present, we need to create it
            Earning           = new DailyEarning();
            Earning.SumAmount = new Money(0);
            Earning.DateDay   = date.Date;
            Earning.Type      = type;
        }
        else
        {
            Earning = result[0];
        }

        return(Earning);
    }
Example #3
0
    public static Money GetEarnings(EarningsStatsType type, DateTime day)
    {
        DailyEarning Earning = DailyEarning.GetProperObject(type, day.Date);

        return(Earning.SumAmount);
    }
Example #4
0
 public static void Subtract(EarningsStatsType type, Money amount)
 {
     Add(type, amount * -1);
 }