示例#1
0
 public List <Payment> GetPaymentsBymemberId(int memberId)
 {
     using (IWNContext context = new IWNContext())
     {
         return(context.Payments.Where(payment => payment.MemberId == memberId).ToList());
     }
 }
示例#2
0
 private void AddPayment(Payment payment)
 {
     using (IWNContext context = new IWNContext())
     {
         context.Payments.Add(payment);
         context.SaveChanges();
     }
 }
示例#3
0
 public void UpdateMember(Member member)
 {
     using (var context = new IWNContext())
     {
         context.Members.Attach(member);
         context.Entry(member).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
示例#4
0
        public Task <List <Member> > GetAllMembers()
        {
            return(Task.Run(() =>
            {
                using (var context = new IWNContext())
                {
                    return context.Members.Include(m => m.Payments).Where(member => member.State != State.Deleted)

                    .ToList();
                }
            }));
        }
示例#5
0
 public void SavePayment(Payment payment)
 {
     if (payment.TransactionId == 0)
     {
         AddPayment(payment);
     }
     using (IWNContext context = new IWNContext())
     {
         context.Payments.Attach(payment);
         context.Entry(payment).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
示例#6
0
 public Member AddMember(Member member)
 {
     if (member.MemberId != 0)
     {
         UpdateMember(member);
     }
     else
     {
         using (var context = new IWNContext())
         {
             context.Members.Add(member);
             context.SaveChanges();
         }
     }
     return(member);
 }
示例#7
0
        public void DeleteMembers(int memberId)
        {
            using (var context = new IWNContext())
            {
                var memberToDelete = context.Members.First(member => member.MemberId == memberId);
                if (memberToDelete == null)
                {
                    return;
                }

                memberToDelete.State = State.Deleted;
                context.Entry(memberToDelete).State = System.Data.Entity.EntityState.Modified;


                context.SaveChanges();
            }
        }