Ejemplo n.º 1
0
 public async Task UpdateAsync(TClass item)
 {
     using (SoccerIdDBContext context = new SoccerIdDBContext())
     {
         context.Entry(context.Set <TClass>()).State = EntityState.Modified;
         await context.SaveChangesAsync();
     }
 }
Ejemplo n.º 2
0
 public void Update(TClass item)
 {
     using (SoccerIdDBContext context = new SoccerIdDBContext())
     {
         context.Entry(item).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Ejemplo n.º 3
0
 public async Task RemoveAsync(int teamId, int userId)
 {
     using (SoccerIdDBContext context = new SoccerIdDBContext())
     {
         var userArchTeam = context.UsersArchiveTeams.FirstOrDefault(t => t.ArchiveTeam_Id == teamId && t.User_Id == userId);
         context.Entry(userArchTeam).State = System.Data.Entity.EntityState.Deleted;
         await context.SaveChangesAsync();
     }
 }
Ejemplo n.º 4
0
 public override async Task RemoveAsync(int id)
 {
     using (SoccerIdDBContext context = new SoccerIdDBContext())
     {
         var chat = context.Chats.FirstOrDefault(t => t.Id == id);
         context.Entry(chat).State = System.Data.Entity.EntityState.Deleted;
         await context.SaveChangesAsync();
     }
 }
Ejemplo n.º 5
0
 public override void Remove(int id)
 {
     using (SoccerIdDBContext context = new SoccerIdDBContext())
     {
         var playingPosition = context.PlayingPositions.FirstOrDefault(t => t.Id == id);
         context.Entry(playingPosition).State = System.Data.Entity.EntityState.Deleted;
         context.SaveChanges();
     }
 }
Ejemplo n.º 6
0
 public override void Remove(int id)
 {
     using (SoccerIdDBContext context = new SoccerIdDBContext())
     {
         var agreedPlayersList = context.AgreedPlayersLists.FirstOrDefault(t => t.Id == id);
         context.Entry(agreedPlayersList).State = System.Data.Entity.EntityState.Deleted;
         context.SaveChanges();
     }
 }
Ejemplo n.º 7
0
 public override void Remove(int id)
 {
     using (SoccerIdDBContext context = new SoccerIdDBContext())
     {
         var eventType = context.EventTypes.FirstOrDefault(t => t.Id == id);
         context.Entry(eventType).State = System.Data.Entity.EntityState.Deleted;
         context.SaveChanges();
     }
 }
Ejemplo n.º 8
0
 public override void Remove(int id)
 {
     using (SoccerIdDBContext context = new SoccerIdDBContext())
     {
         var message = context.Set <TClass>().FirstOrDefault(t => t.Id == id);
         context.Entry(message).State = System.Data.Entity.EntityState.Deleted;
         context.SaveChanges();
     }
 }
 public override void Remove(int id)
 {
     using (SoccerIdDBContext context = new SoccerIdDBContext())
     {
         var archiveTeam = context.ArchiveTeams.FirstOrDefault(t => t.Id == id);
         context.Entry(archiveTeam).State = System.Data.Entity.EntityState.Deleted;
         context.SaveChanges();
     }
 }
Ejemplo n.º 10
0
 public override async Task <Chat> GetByIdAsync(int id)
 {
     using (SoccerIdDBContext context = new SoccerIdDBContext())
     {
         return(await Task <Chat> .Factory.StartNew(() =>
         {
             return context.Chats.Where(t => t.Id == id).FirstOrDefault();
         }));
     }
 }
Ejemplo n.º 11
0
        public override Chat GetById(int id)
        {
            Chat result = null;

            using (SoccerIdDBContext context = new SoccerIdDBContext())
            {
                result = context.Chats.Where(t => t.Id == id).FirstOrDefault();
            }
            return(result);
        }
Ejemplo n.º 12
0
 public async Task <UserArchiveTeam> GetByIdAsync(int teamId, int userId)
 {
     using (SoccerIdDBContext context = new SoccerIdDBContext())
     {
         return(await Task <UserArchiveTeam> .Factory.StartNew(() =>
         {
             return context.UsersArchiveTeams.Where(t => t.ArchiveTeam_Id == teamId && t.User_Id == userId).FirstOrDefault();
         }));
     }
 }
Ejemplo n.º 13
0
        public override TClass GetById(int id)
        {
            TClass result = null;

            using (SoccerIdDBContext context = new SoccerIdDBContext())
            {
                result = context.Set <TClass>().Where(t => t.Id == id).FirstOrDefault();
            }
            return(result);
        }
Ejemplo n.º 14
0
        public override async Task <Team> GetByIdAsync(int id)
        {
            Team result = null;

            using (SoccerIdDBContext context = new SoccerIdDBContext())
            {
                result = await context.Teams.Where(t => t.Id == id).FirstOrDefaultAsync();
            }
            return(result);
        }
Ejemplo n.º 15
0
 public async Task <IEnumerable <TClass> > GetAllAsync()
 {
     using (SoccerIdDBContext context = new SoccerIdDBContext())
     {
         return(await Task <IEnumerable <TClass> > .Factory.StartNew(() => {
             return (from t in context.Set <TClass>()
                     select t).ToList();
         }));
     }
 }
Ejemplo n.º 16
0
        public override PlayingPosition GetById(int id)
        {
            PlayingPosition result = null;

            using (SoccerIdDBContext context = new SoccerIdDBContext())
            {
                result = context.PlayingPositions.Where(t => t.Id == id).FirstOrDefault();
            }
            return(result);
        }
Ejemplo n.º 17
0
        public override AgreedPlayersList GetById(int id)
        {
            AgreedPlayersList result = null;

            using (SoccerIdDBContext context = new SoccerIdDBContext())
            {
                result = context.AgreedPlayersLists.Where(t => t.Id == id).FirstOrDefault();
            }
            return(result);
        }
        public override ArchiveTeam GetById(int id)
        {
            ArchiveTeam result = null;

            using (SoccerIdDBContext context = new SoccerIdDBContext())
            {
                result = context.ArchiveTeams.Where(t => t.Id == id).FirstOrDefault();
            }
            return(result);
        }
Ejemplo n.º 19
0
        //[Authorize(Roles ="admin")]
        public ActionResult GetUsers()        //получение инф-и о пользователях
        {
            List <User> users = new List <User>();

            using (SoccerIdDBContext db = new SoccerIdDBContext())
            {
                users = db.Users.ToList();
            }
            return(View(users));
        }
Ejemplo n.º 20
0
        public override EventType GetById(int id)
        {
            EventType result = null;

            using (SoccerIdDBContext context = new SoccerIdDBContext())
            {
                result = context.EventTypes.Where(t => t.Id == id).FirstOrDefault();
            }
            return(result);
        }
Ejemplo n.º 21
0
        public UserArchiveTeam GetById(int teamId, int userId)
        {
            UserArchiveTeam result = null;

            using (SoccerIdDBContext context = new SoccerIdDBContext())
            {
                result = context.UsersArchiveTeams.Where(t => t.ArchiveTeam_Id == teamId && t.User_Id == userId).FirstOrDefault();
            }
            return(result);
        }
Ejemplo n.º 22
0
        public IEnumerable <TClass> GetAll()
        {
            IEnumerable <TClass> result = null;

            using (SoccerIdDBContext context = new SoccerIdDBContext())
            {
                result = (from t in context.Set <TClass>()
                          select t).ToList();
            }
            return(result);
        }
Ejemplo n.º 23
0
        public async Task <TClass> AddAsync(TClass item)
        {
            TClass result = null;

            using (SoccerIdDBContext context = new SoccerIdDBContext())
            {
                result = context.Set <TClass>().Add(item);
                await context.SaveChangesAsync();
            }
            return(result);
        }
Ejemplo n.º 24
0
        public TClass Add(TClass item)
        {
            TClass result = null;

            using (SoccerIdDBContext context = new SoccerIdDBContext())
            {
                result = context.Set <TClass>().Add(item);
                context.SaveChanges();
            }
            return(result);
        }
Ejemplo n.º 25
0
 public async Task <IEnumerable <TClass> > FindAsync(Func <TClass, bool> predicate, string navigationProperty = "")
 {
     using (SoccerIdDBContext context = new SoccerIdDBContext())
     {
         return(await Task <IEnumerable <TClass> > .Factory.StartNew(() =>
         {
             if (String.IsNullOrEmpty(navigationProperty))
             {
                 return (from t in context.Set <TClass>().Where(predicate)
                         select t).ToList();
             }
             else
             {
                 return (from t in context.Set <TClass>().Include(navigationProperty).Where(predicate)
                         select t).ToList();
             }
         }));
     }
 }
Ejemplo n.º 26
0
        public IEnumerable <TClass> Find(Func <TClass, bool> predicate, string navigationProperty = "")
        {
            IEnumerable <TClass> result = null;

            using (SoccerIdDBContext context = new SoccerIdDBContext())
            {
                if (String.IsNullOrEmpty(navigationProperty))
                {
                    result = (from t in context.Set <TClass>().Where(predicate)
                              select t).ToList();
                }
                else
                {
                    result = (from t in context.Set <TClass>().Include(navigationProperty).Where(predicate)
                              select t).ToList();
                }
            }
            return(result);
        }