public void AddDeposit(Deposit deposit)
 {
     using (var ctx = new SimchaContext(_connectionString))
     {
         ctx.Deposits.Add(deposit);
         ctx.SaveChanges();
     }
 }
 public void AddContributor(Contributor contributor)
 {
     using (var ctx = new SimchaContext(_connectionString))
     {
         ctx.Contributors.Add(contributor);
         ctx.SaveChanges();
     }
 }
 public void AddSimcha(Simcha simcha)
 {
     using (var ctx = new SimchaContext(_connectionString))
     {
         ctx.Simchas.Add(simcha);
         ctx.SaveChanges();
     }
 }
 public void DeleteContributions(int simchaId)
 {
     using (var ctx = new SimchaContext(_connectionString))
     {
         ctx.Contributions.RemoveRange(ctx.Contributions.Where(c => c.SimchaId == simchaId));
         ctx.SaveChanges();
     }
 }
 public void EditContributor(Contributor contributor)
 {
     using (var ctx = new SimchaContext(_connectionString))
     {
         ctx.Database.ExecuteSqlCommand(
             "UPDATE Contributors SET Name = @name, Cell = @cell, DateJoined=@datejoined, AlwaysInclude = @alwaysinclude WHERE Id = @id",
             new SqlParameter("@id", contributor.Id), new SqlParameter("@name", contributor.Name),
             new SqlParameter("@cell", contributor.Cell), new SqlParameter("@alwaysinclude", contributor.AlwaysInclude),
             new SqlParameter("@datejoined", contributor.DateJoined));
         ctx.SaveChanges();
     }
 }
        public void UpdateContributions(IEnumerable <SimchaContributor> contributors, int simchaId)
        {
            IEnumerable <SimchaContributor> con = contributors.Where(c => c.Contributed);

            using (var ctx = new SimchaContext(_connectionString))
            {
                foreach (SimchaContributor sc in con)
                {
                    ctx.Contributions.Add(new Contribution {
                        ContributorId = sc.ContributorId, SimchaId = sc.SimchaId, Amount = sc.Amount
                    });
                }
                ctx.SaveChanges();
            }
        }