예제 #1
0
 public async Task <Payout> GetById(int payoutId)
 {
     using (var context = new MineContext())
     {
         return(await context.Wyplaty.AsNoTracking().SingleAsync(x => x.PayoutId == payoutId));
     }
 }
예제 #2
0
 public async Task <List <Payout> > GetWithFilter(Expression <Func <Payout, bool> > filter)
 {
     using (var context = new MineContext())
     {
         return(await context.Wyplaty.AsNoTracking().AsQueryable().Where(filter).ToListAsync());
     }
 }
예제 #3
0
 public async Task <bool> Exists(string firstName, string LastName, DateTime birth)
 {
     using (var context = new MineContext())
     {
         return(await context.Persons.AnyAsync(x => x.FirstName == firstName && x.LastName == LastName && x.BirthDate == birth.Date));
     }
 }
예제 #4
0
 public async Task <Person> GetById(int personId)
 {
     using (var context = new MineContext())
     {
         return(await context.Persons.AsNoTracking().SingleAsync(x => x.PersonId == personId));
     }
 }
예제 #5
0
 public async Task <List <Person> > GetAll()
 {
     using (var context = new MineContext())
     {
         return(await context.Persons.AsNoTracking().ToListAsync());
     }
 }
예제 #6
0
        public async Task <Payout> Create(Payout payout)
        {
            using (var context = new MineContext())
            {
                context.Wyplaty.Add(payout);
                await context.SaveChangesAsync();
            }

            return(payout);
        }
예제 #7
0
        public async Task <Person> Create(Person person)
        {
            using (var context = new MineContext())
            {
                context.Persons.Add(person);
                await context.SaveChangesAsync();
            }

            return(person);
        }
예제 #8
0
        public async Task <MoneyCount> Create(MoneyCount kasa)
        {
            using (var context = new MineContext())
            {
                context.Kasa.Add(kasa);
                await context.SaveChangesAsync();
            }

            return(kasa);
        }
예제 #9
0
        public async Task Delete(int personId)
        {
            using (var context = new MineContext())
            {
                var person = await context.Persons.SingleAsync(x => x.PersonId == personId);

                context.Entry(person).State = EntityState.Deleted;

                await context.SaveChangesAsync();
            }
        }
예제 #10
0
        public async Task <Payout> Update(Payout payout)
        {
            using (var context = new MineContext())
            {
                context.Wyplaty.Attach(payout);
                context.Entry(payout).State = EntityState.Unchanged;

                context.Entry(payout).Property(a => a.Amount).IsModified      = true;
                context.Entry(payout).Property(a => a.Description).IsModified = true;
                context.Entry(payout).Property(a => a.CreatedOn).IsModified   = true;
                context.Entry(payout).Property(a => a.Lokalizacja).IsModified = true;

                await context.SaveChangesAsync();
            }

            return(payout);
        }
예제 #11
0
        public async Task <Person> Update(Person person)
        {
            using (var context = new MineContext())
            {
                context.Persons.Attach(person);
                context.Entry(person).State = EntityState.Unchanged;

                context.Entry(person).Property(a => a.Address).IsModified     = true;
                context.Entry(person).Property(a => a.FirstName).IsModified   = true;
                context.Entry(person).Property(a => a.LastName).IsModified    = true;
                context.Entry(person).Property(a => a.BirthDate).IsModified   = true;
                context.Entry(person).Property(a => a.Lokalizacja).IsModified = true;

                await context.SaveChangesAsync();
            }

            return(person);
        }