コード例 #1
0
ファイル: Videogames.cs プロジェクト: agarca/Proyecto-Modulo2
 public void Delete()
 {
     try
     {
         GamesDBContext context = new GamesDBContext();
         context.Entry(this).State = System.Data.Entity.EntityState.Deleted;
         context.SaveChanges();
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #2
0
ファイル: Videogames.cs プロジェクト: agarca/Proyecto-Modulo2
        public static List <Videogames> SelectAll()
        {
            List <Videogames> videogames = new List <Videogames>();

            try
            {
                GamesDBContext context = new GamesDBContext();
                videogames = context.Videogames.OrderBy(x => x.name).ToList();
            }
            catch (Exception)
            {
                throw;
            }
            return(videogames);
        }
コード例 #3
0
ファイル: Videogames.cs プロジェクト: agarca/Proyecto-Modulo2
        public static Videogames Get(int id)
        {
            Videogames videogames = new Videogames();

            try
            {
                GamesDBContext context = new GamesDBContext();
                videogames = context.Videogames.Where(x => x.id == id).SingleOrDefault();
            }
            catch (Exception)
            {
                throw;
            }
            return(videogames);
        }
コード例 #4
0
ファイル: Videogames.cs プロジェクト: agarca/Proyecto-Modulo2
        public static List <Videogames> SelectRanking()
        {
            List <Videogames> videogames = new List <Videogames>();

            try
            {
                GamesDBContext context = new GamesDBContext();
                videogames = context.Videogames.OrderByDescending(x => x.score).ToList();
            }
            catch (Exception)
            {
                throw;
            }
            return(videogames);
        }
コード例 #5
0
        public ActionResult Search(string word)
        {
            IEnumerable <Videogames> videogames;

            using (var bd = new GamesDBContext())
            {
                videogames = bd.Videogames;
                if (!string.IsNullOrEmpty(word))
                {
                    videogames = videogames.Where(x => x.name.ToLower().Contains(word.ToLower()));
                    videogames = videogames.ToList();
                    return(View(videogames));
                }
                else
                {
                    return(Redirect("~/"));
                }
            }
        }
コード例 #6
0
ファイル: Videogames.cs プロジェクト: agarca/Proyecto-Modulo2
        public void Save()
        {
            bool create = this.id == 0;

            try
            {
                GamesDBContext context = new GamesDBContext();
                if (create)
                {
                    context.Entry(this).State = System.Data.Entity.EntityState.Added;
                }
                else
                {
                    context.Entry(this).State = System.Data.Entity.EntityState.Modified;
                }
                context.SaveChanges();
            }
            catch (Exception)
            {
                throw;
            }
        }