예제 #1
0
 public List <Category> GetAll()
 {
     try
     {
         using (var context = new AppContext())
         {
             return(context.Categories.ToList());
         }
     }catch (Exception ex)
     {
         Console.Write(ex);
         throw ex;
     }
 }
예제 #2
0
        public Nationality GetById(int id)
        {
            Nationality nationality;

            try
            {
                using (var context = new AppContext())
                {
                    nationality = context.Nationality.SingleOrDefault(n => n.NationalityId == id);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                throw;
            }

            return(nationality);
        }
예제 #3
0
        public List <Nationality> getAll()
        {
            List <Nationality> nationalities;

            try
            {
                using (var context = new AppContext())
                {
                    nationalities = context.Nationality.ToList();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                throw;
            }

            return(nationalities);
        }
예제 #4
0
        public bool Delete(int id)
        {
            Nationality dbNationality;

            try
            {
                using (var context = new AppContext())
                {
                    dbNationality = GetById(id);
                    context.Nationality.Remove(dbNationality);
                    context.SaveChanges();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                throw ex;
            }
        }
예제 #5
0
        public Nationality Add(Nationality nationality)
        {
            Nationality dbNationality;

            try
            {
                using (var context = new AppContext())
                {
                    dbNationality = context.Nationality.Add(nationality);
                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                throw;
            }

            return(dbNationality);
        }
예제 #6
0
        public Nationality Update(Nationality nationality)
        {
            try
            {
                using (var context = new AppContext())
                {
                    if (nationality != null)
                    {
                        context.Nationality.Attach(nationality);
                        context.Entry(nationality).State = EntityState.Modified;
                        context.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                throw;
            }

            return(nationality);
        }
예제 #7
0
 public CategoryRepository(AppContext context)
 {
     _context = context;
 }
예제 #8
0
 public NationalityRepository(AppContext context)
 {
     _context = context;
 }
예제 #9
0
 public MatchRepository(AppContext context)
 {
     _context = context;
 }