Exemplo n.º 1
0
 public int GetContributorCount()
 {
     using (var context = new ContributorDataContext(_connectionString))
     {
         return(context.Contributors.Count());
     }
 }
Exemplo n.º 2
0
 public Contributor GetContributorById(int id)
 {
     using (var context = new ContributorDataContext(_connectionString))
     {
         return(context.Contributors.FirstOrDefault(c => c.Id == id));
     }
 }
Exemplo n.º 3
0
 public void AddContributor(Contributor contributor)
 {
     using (var context = new ContributorDataContext(_connectionString))
     {
         context.Contributors.InsertOnSubmit(contributor);
         context.SubmitChanges();
     }
 }
Exemplo n.º 4
0
 public void UpdateContributor(Contributor contributor)
 {
     using (var context = new ContributorDataContext(_connectionString))
     {
         context.Contributors.Attach(contributor);
         context.Refresh(RefreshMode.KeepCurrentValues, contributor);
         context.SubmitChanges();
     }
 }
Exemplo n.º 5
0
        public IEnumerable <Contributor> GetContributors()
        {
            List <Contributor> contributors = new List <Contributor>();

            using (var context = new ContributorDataContext(_connectionString))
            {
                contributors = context.Contributors.ToList();
            }
            foreach (Contributor c in contributors)
            {
                c.Balance = GetContributorBalance(c.Id);
            }
            return(contributors.AsEnumerable());
        }