public async Task <IEnumerable <Pub> > GetAllAsync()
 {
     try
     {
         return(_dbContext.Pubs);
     }
     catch (Exception e)
     {
         HandyHelper.ErrorMessage(_fileName, "GetAllAsync", e.Message);
         return(null);
     }
 }
        public async Task <Pub> GetByIdAsync(int id)
        {
            try
            {
                var p = await _dbContext.Pubs.FindAsync(id);

                return(p);
            }
            catch (Exception e)
            {
                HandyHelper.ErrorMessage(_fileName, "GetByIdAsync", e.Message);
                return(null);
            }
        }
예제 #3
0
        public async Task <Member> GetByIdAsync(int id)
        {
            try
            {
                var x = await _dbContext.Members.FindAsync(id);

                return(x);
            }
            catch (Exception e)
            {
                HandyHelper.ErrorMessage(fileName, "GetByIdAsync", e.Message);
                return(null);
            }
        }
        public async Task <Pub> UpdateAsync(Pub pubChanges)
        {
            try
            {
                var pub = _dbContext.Pubs.Attach(pubChanges);
                pub.State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                await _dbContext.SaveChangesAsync();

                return(pubChanges);
            }
            catch (Exception e)
            {
                HandyHelper.ErrorMessage(_fileName, "UpdateAsync", e.Message);
                return(null);
            }
        }
        public async Task <Pub> CreateAsync(Pub pub)
        {
            try
            {
                await _dbContext.Pubs.AddAsync(pub);

                await _dbContext.SaveChangesAsync();

                return(pub);
            }
            catch (Exception e)
            {
                HandyHelper.ErrorMessage(_fileName, "CreateAsync", e.Message);
                return(null);
            }
        }
예제 #6
0
        public async Task <Member> UpdateAsync(Member memberChanges)
        {
            try
            {
                var m = _dbContext.Members.Attach(memberChanges);
                m.State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                await _dbContext.SaveChangesAsync();

                return(memberChanges);
            }
            catch (Exception e)
            {
                HandyHelper.ErrorMessage(fileName, "UpdateAsync", e.Message);
                return(null);
            }
        }
예제 #7
0
        public async Task <Member> CreateAsync(Member member)
        {
            try
            {
                await _dbContext.Members.AddAsync(member);

                await _dbContext.SaveChangesAsync();

                return(member);
            }
            catch (Exception e)
            {
                HandyHelper.ErrorMessage(fileName, "CreateAsync", e.Message);
                return(null);
            }
        }
        public async Task <Pub> DeleteAsync(int id)
        {
            try
            {
                Pub p = await _dbContext.Pubs.FindAsync(id);

                if (p != null)
                {
                    _dbContext.Pubs.Remove(p);
                    await _dbContext.SaveChangesAsync();
                }
                return(p);
            }
            catch (Exception e)
            {
                HandyHelper.ErrorMessage(_fileName, "DeleteAsync", e.Message);
                return(null);
            }
        }
예제 #9
0
        public async Task <Member> DeleteAsync(int id)
        {
            try
            {
                Member member = await _dbContext.Members.FindAsync(id);

                if (member != null)
                {
                    _dbContext.Members.Remove(member);
                    await _dbContext.SaveChangesAsync();
                }
                return(member);
            }
            catch (Exception e)
            {
                HandyHelper.ErrorMessage(fileName, "DeleteAsync", e.Message);
                return(null);
            }
        }