public bool addOutcome(MoneyDTO outcome)
        {
            bool IsAdded = false;

            if (outcome.Value.Equals(0) || outcome.Value.Equals(""))
            {
                throw new ArgumentException("You haven't typed anything in the value field.");
            }
            else if (outcome.Value < 1000)
            {
                throw new ArgumentException("Outcome value must be at least 1000.");
            }

            try
            {
                var outc = new Outcomes();
                outc.Value    = outcome.Value;
                outc.Type     = outcome.Type;
                outc.Duration = outcome.Duration;
                outc.Total    = outcome.Value * outcome.Duration;
                OutcomeEntities.Outcomes.Add(outc);
                var NoOfRowsAffected = OutcomeEntities.SaveChanges();
                IsAdded = NoOfRowsAffected > 0;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(IsAdded);
        }
Beispiel #2
0
        public bool addIncome(MoneyDTO income)
        {
            bool IsAdded = false;

            if (income.Value.Equals(0) || income.Value.Equals(""))
            {
                throw new ArgumentException("You haven't typed anything in the value field.");
            }
            else if (income.Value < 1000)
            {
                throw new ArgumentException("Income value must be at least 1000.");
            }

            try
            {
                var inc = new Incomes();
                inc.Value    = income.Value;
                inc.Type     = income.Type;
                inc.Duration = income.Duration;
                inc.Total    = income.Value * income.Duration;
                IncomeEntities.Incomes.Add(inc);
                var NoOfRowsAffected = IncomeEntities.SaveChanges();
                IsAdded = NoOfRowsAffected > 0;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(IsAdded);
        }