Example #1
0
 public void AddPersonName(string PersonName)
 {
     using (var db = new InvestmentdbContext())
     {
         db.Add(new People {
             Name = PersonName
         });
         db.SaveChanges();
     }
 }
Example #2
0
 public void AddExpenditure(float amount, string purpose, string name)
 {
     if (amount <= 0)
     {
         throw new Exception("Invalid input");
     }
     else
     {
         using (var db = new InvestmentdbContext())
         {
             var q2 = db.Peoples.Where(p => p.Name == name);
             foreach (var p in q2)
             {
                 db.Add(new Expenditure {
                     ExpenseAmount = amount, Day = DateTime.Now, PurposeOfExpenditure = purpose, PeopleId = p.PeopleId
                 });
             }
             db.SaveChanges();
         }
     }
 }
Example #3
0
        // Adding entry to database with exception handling
        public void AddIncome(float amount, string source, string name)
        {
            if (amount <= 0)
            {
                throw new Exception("Invalid input");
            }
            else
            {
                using (var db = new InvestmentdbContext())
                {
                    var q1 = db.Peoples.Where(p => p.Name == name);

                    foreach (var p in q1)
                    {
                        db.Add(new Income {
                            IncomeReceived = amount, Day = DateTime.Now, SourceOfIncome = source, PeopleId = p.PeopleId
                        });
                    }

                    db.SaveChanges();
                }
            }
        }