public static void Add(EarningsStatsType type, Money amount) { DailyEarning Earning = DailyEarning.GetProperObject(type, DateTime.Now.Date); //Add & save Earning.SumAmount += amount; Earning.Save(); }
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); }
public static Money GetEarnings(EarningsStatsType type, DateTime day) { DailyEarning Earning = DailyEarning.GetProperObject(type, day.Date); return(Earning.SumAmount); }
public static void Subtract(EarningsStatsType type, Money amount) { Add(type, amount * -1); }