示例#1
0
 public GamesDB GetGame(int id)
 {
     using (GamesEntities entities = new GamesEntities())
     {
         return(entities.GamesDBs.FirstOrDefault(p => p.Id == id));
     }
 }
示例#2
0
 public IEnumerable <GamesDB> GetAllGame()
 {
     using (GamesEntities entities = new GamesEntities())
     {
         return(entities.GamesDBs.ToList());
     }
 }
示例#3
0
 public ActionResult Slider()
 {
     using (var _Entity = new GamesEntities())
     {
         var lst = _Entity.SliderVs.ToList();
         return(View(lst));
     }
 }
示例#4
0
 public PartialViewResult Slider()
 {
     using (var _Entity = new GamesEntities())
     {
         var lst = _Entity.SliderVs.OrderByDescending(o => o.ProductId).ToList();
         return(PartialView("_Slider", lst));
     }
 }
示例#5
0
 public ActionResult Images(int id)
 {
     using (var _Entity = new GamesEntities())
     {
         var lst = _Entity.ProductImages.Where(g => g.ProductId == id).ToList();
         return(View(lst));
     }
 }
示例#6
0
        public ActionResult UploadSlider(string id)
        {
            // Checking no of files injected in Request object
            if (Request.Files.Count > 0)
            {
                try
                {
                    //  Get all files from Request object
                    HttpFileCollectionBase files = Request.Files;
                    for (int i = 0; i < files.Count; i++)
                    {
                        //string path = AppDomain.CurrentDomain.BaseDirectory + "Uploads/";
                        //string filename = Path.GetFileName(Request.Files[i].FileName);

                        HttpPostedFileBase file = files[i];
                        string             fname;

                        // Checking for Internet Explorer
                        if (Request.Browser.Browser.ToUpper() == "IE" || Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER")
                        {
                            string[] testfiles = file.FileName.Split(new char[] { '\\' });
                            fname = Guid.NewGuid().ToString() + "_" + DateTime.Today.ToShortDateString().Replace("/", "_").ToString();;
                        }
                        else
                        {
                            fname = Guid.NewGuid().ToString() + "_" + DateTime.Today.ToShortDateString().Replace("/", "_").ToString();;
                        }

                        string fileName = fname + Path.GetExtension(file.FileName);

                        // Get the complete folder path and store the file inside it.
                        fname = Path.Combine(Server.MapPath("~/Images/"), fname + Path.GetExtension(file.FileName));
                        file.SaveAs(fname);

                        using (var _Entity = new GamesEntities())
                        {
                            ProductImage model = new ProductImage();
                            model.ProductId            = Convert.ToInt32(id);
                            model.ImagePath            = fileName;
                            model.Type                 = "Slider";
                            _Entity.Entry(model).State = EntityState.Added;
                            _Entity.SaveChanges();
                            TempData["Result"] = "Game Sucessfully Updated.";
                        }
                    }
                    // Returns message that successfully uploaded
                    return(Json("Image Uploaded Successfully!"));
                }
                catch (Exception ex)
                {
                    return(Json("Error occurred. Error details: " + ex.Message));
                }
            }
            else
            {
                return(Json("No files selected."));
            }
        }
示例#7
0
 public ActionResult Order(int Id)
 {
     Session["OrderId"] = Id;
     using (var _Entity = new GamesEntities())
     {
         var lst = _Entity.Orders.Where(o => o.OrderId == Id).FirstOrDefault();
         return(View(lst));
     }
 }
示例#8
0
        public List <ProductV1> GetProductList()
        {
            using (var _Entity = new GamesEntities())
            {
                var lst = _Entity.ProductV1.ToList().
                          OrderByDescending(e => e.ProductId).ToList();

                return(lst);
            }
        }
示例#9
0
        public PartialViewResult Items()
        {
            int Id = Convert.ToInt32(Session["OrderId"].ToString());

            using (var _Entity = new GamesEntities())
            {
                var lst = _Entity.OrderDetails.Where(o => o.OrderId == Id).ToList();
                return(PartialView("_Items", lst));
            }
        }
示例#10
0
 public JsonResult GetOrderList()
 {
     using (var _Entity = new GamesEntities())
     {
         var            lst  = _Entity.OrderVs.OrderByDescending(o => o.Date).ToList();
         GridDataSource gobj = new GridDataSource
         {
             data   = lst.ToList(),
             length = lst.Count
         };
         return(Json(gobj, JsonRequestBehavior.AllowGet));
     }
 }
示例#11
0
 public ActionResult Game()
 {
     using (var _Entity = new GamesEntities())
     {
         IEnumerable <SelectListItem> items = _Entity.Genres.Select(c => new SelectListItem
         {
             Value = c.GenreId.ToString(),
             Text  = c.Genre1
         }).ToList();
         ViewBag.Genres = items;
         return(View());
     }
 }
示例#12
0
 // GET: Exchange
 public ActionResult Exchange(string type)
 {
     Session["tt"] = type;
     using (var _Entity = new GamesEntities())
     {
         IEnumerable <SelectListItem> items = _Entity.Exchanges.Where(g => g.Platform.Contains(type)).Select(c => new SelectListItem
         {
             Value = c.ExchangeId.ToString(),
             Text  = c.Title
         }).ToList();
         ViewBag.Games = items;
         return(View());
     }
 }
示例#13
0
        public JsonResult DoExchange(int ClientGameId, int StoreGameId)
        {
            Exchange clientGame = new Exchange();
            Exchange storeGame  = new Exchange();

            using (var _Entity = new GamesEntities())
            {
                clientGame = _Entity.Exchanges
                             .Where(g => g.ExchangeId == ClientGameId).FirstOrDefault();
                storeGame = _Entity.Exchanges
                            .Where(g => g.ExchangeId == StoreGameId).FirstOrDefault();
            }

            var payment = storeGame.StorePrice - clientGame.BuyingPrice;

            return(Json(payment, JsonRequestBehavior.AllowGet));
        }
示例#14
0
 public JsonResult ExchangeEdit(int Id)
 {
     try
     {
         Exchange model = new Exchange();
         using (var _Entity = new GamesEntities())
         {
             model = _Entity.Exchanges.Where(x => x.ExchangeId == Id).FirstOrDefault();
         }
         //TempData["EAccountmodel"] = model;
         return(Json(model, JsonRequestBehavior.AllowGet));
     }
     catch (Exception e)
     {
         return(Json(e.Message.ToString(), JsonRequestBehavior.AllowGet));
     }
 }
示例#15
0
 public ActionResult AddExchange(Exchange model)
 {
     try
     {
         using (var _Entity = new GamesEntities())
         {
             _Entity.Entry(model).State = (model.ExchangeId == 0 ? EntityState.Added : EntityState.Modified);
             _Entity.SaveChanges();
             TempData["Result"] = "Game Sucessfully Updated.";
             return(RedirectToAction("ExchangeList"));
         }
     }
     catch (Exception e)
     {
         TempData["Error"] = "Error : " + e.Message.ToString();
         return(RedirectToAction("ExchangeList"));
     }
 }
示例#16
0
 public JsonResult GetProductdrp()
 {
     try
     {
         using (var _Entity = new GamesEntities())
         {
             var lst = _Entity.Products.Where(g => g.Type == "Game").Select(x => new
             {
                 ID   = x.ProductId,
                 Name = x.Title
             }).ToList();
             return(Json(lst, JsonRequestBehavior.AllowGet));
         }
     }
     catch
     {
         return(Json("[]", JsonRequestBehavior.AllowGet));
     }
 }
示例#17
0
 public JsonResult GetTagsdrp()
 {
     try
     {
         using (var _Entity = new GamesEntities())
         {
             var lst = _Entity.Genres.Select(x => new
             {
                 ID   = x.GenreId,
                 Name = x.Genre1
             }).ToList();
             return(Json(lst, JsonRequestBehavior.AllowGet));
         }
     }
     catch
     {
         return(Json("[]", JsonRequestBehavior.AllowGet));
     }
 }
示例#18
0
        public JsonResult GetGameImagesList(int Id)
        {
            //if (Session["UserID"] != null)
            //{
            using (var _Entity = new GamesEntities())
            {
                var            lst  = _Entity.Products.Where(g => g.ProductId == Id).ToList();
                GridDataSource gobj = new GridDataSource
                {
                    data   = lst.ToList(),
                    length = lst.Count
                };
                return(Json(gobj, JsonRequestBehavior.AllowGet));
            }

            //}
            //else
            //    return Json("[]");
        }
示例#19
0
        public void TesteListarJogos()
        {
            List <int> plataformas = new List <int> {
                1, 2
            };
            int               status = 2;
            GamesEntities     db     = new GamesEntities();
            List <GameEntity> ListaJogos;

            int[] plats = plataformas.ToArray();
            ListaJogos = (from game in db.game
                          join game_platform in db.game_platform on game.id equals game_platform.id_game
                          where plats.Contains(game_platform.id_platform)
                          where game_platform.id_status == status
                          select game).OrderBy(game => game.name).ToList();

            //DateTime a = ListaJogos[0].game_platform.First().release_date;
            Assert.IsNotNull(ListaJogos);
        }
示例#20
0
        public ActionResult AddProduct(Product model)
        {
            string Action      = "Index";
            string DefaultView = "Product";

            if (model.Type == "Game")
            {
                Action      = "Index";
                DefaultView = "Game";
            }

            if (model.Type == "Acc")
            {
                Action = "AccList";
            }
            if (model.Type == "Console")
            {
                Action = "Consoles";
            }

            try
            {
                //if (!ModelState.IsValid)
                //    return View("Game");

                using (var _Entity = new GamesEntities())
                {
                    _Entity.Entry(model).State = (model.ProductId == 0 ? EntityState.Added : EntityState.Modified);
                    _Entity.SaveChanges();
                    TempData["Result"] = "Game Sucessfully Updated.";



                    return(RedirectToAction(Action));
                }
            }
            catch (Exception e)
            {
                TempData["Error"] = "Error : " + e.Message.ToString();
                return(View(DefaultView));
                //return Json("false", JsonRequestBehavior.AllowGet);
            }
        }
示例#21
0
        public JsonResult GetConsolesList()
        {
            //if (Session["UserID"] != null)
            //{
            using (var _Entity = new GamesEntities())
            {
                var lst = _Entity.Products.Where(g => g.Type == "Console")
                          .OrderByDescending(o => o.ProductId).ToList();
                GridDataSource gobj = new GridDataSource
                {
                    data   = lst.ToList(),
                    length = lst.Count
                };
                return(Json(gobj, JsonRequestBehavior.AllowGet));
            }

            //}
            //else
            //    return Json("[]");
        }
示例#22
0
 public JsonResult OrderDelete(int ID)
 {
     try
     {
         using (var _Entity = new GamesEntities())
         {
             var _Data = _Entity.Orders.Where(x => x.OrderId == ID).SingleOrDefault();
             if (_Data != null)
             {
                 _Entity.Orders.Remove(_Data);
                 _Entity.SaveChanges();
                 return(Json("true", JsonRequestBehavior.AllowGet));
             }
             return(Json("false", JsonRequestBehavior.AllowGet));
         }
     }
     catch
     {
         return(Json("false", JsonRequestBehavior.AllowGet));
     }
 }
示例#23
0
        public async Task TesteMetacritic()
        {
            GamesEntities        db    = new GamesEntities();
            List <game_platform> games = db.game_platform.Where(gp => gp.metacritic == null).ToList();

            foreach (game_platform g in games)
            {
                GameEntity jogo       = db.game.Find(g.id_game);
                platform   plataforma = db.platform.Find(g.id_platform);
                string     sigla;
                switch (plataforma.sigla)
                {
                case "PS1":
                    sigla = "PS";
                    break;

                case "PSVITA":
                    sigla = "VITA";
                    break;

                default:
                    sigla = plataforma.sigla;
                    break;
                }
                try {
                    var metacritic = await Metacritic.SearchFor().Games().UsingTextAsync(jogo.name);

                    var resultado = metacritic.Where(m => m.Platform == sigla).Where(m => m.Name == jogo.name).FirstOrDefault();
                    if (resultado != null)
                    {
                        g.metacritic      = resultado.Score;
                        db.Entry(g).State = EntityState.Modified;
                    }
                }
                catch (Exception ex) {
                }
            }
            db.SaveChanges();
        }
示例#24
0
        public ActionResult DoCheckOut(Order model)
        {
            try
            {
                if (Session["MyCart"] != null)
                {
                    using (var _Entity = new GamesEntities())
                    {
                        model.Date   = DateTime.Now;
                        model.Status = "Pending";
                        _Entity.Entry(model).State = EntityState.Added;
                        _Entity.SaveChanges();

                        List <CartProduct> cart = Session["MyCart"] as List <CartProduct>;
                        foreach (var item in cart)
                        {
                            OrderDetail detail = new OrderDetail();
                            detail.OrderId              = model.OrderId;
                            detail.Product              = item.Name;
                            detail.Type                 = item.Type;
                            detail.Quantity             = Convert.ToInt32(item.Quantity);
                            detail.UnitPrice            = Convert.ToDecimal(item.Price);
                            detail.TotalPrice           = Convert.ToInt32(item.Total);
                            _Entity.Entry(detail).State = EntityState.Added;
                            _Entity.SaveChanges();
                        }
                    }
                }

                Session["op"] = "true";
            }
            catch (Exception ex)
            {
                Session["op"] = "false";
            }
            return(Redirect("Thanks"));
        }
示例#25
0
        public void Teste()
        {
            GamesEntities        db    = new GamesEntities();
            IgdbService          igdb  = new IgdbService();
            List <game_platform> games = db.game_platform.Where(gp => gp.release_date == null).Where(gp => gp.id_status == 1).ToList();

            foreach (game_platform g in games)
            {
                GameEntity jogo = db.game.Find(g.id_game);
                try {
                    platform          plataforma = db.platform.Find(g.id_platform);
                    DadosGameResponse dados      = igdb.DadosJogo(jogo.id_igdb.Value).FirstOrDefault();
                    ReleaseDate       lancamento;
                    if (g.id_region == null)
                    {
                        lancamento = dados.ReleaseDates.Where(r => r.Region == 8).Where(r => r.Platform == plataforma.id_igdb).FirstOrDefault();
                        if (lancamento == null)
                        {
                            lancamento = dados.ReleaseDates.Where(r => r.Region == 2).Where(r => r.Platform == plataforma.id_igdb).FirstOrDefault();
                        }
                        if (lancamento != null)
                        {
                            g.id_region = lancamento.Region;
                        }
                    }
                    else
                    {
                        lancamento = dados.ReleaseDates.Where(r => r.Region == g.id_region).Where(r => r.Platform == plataforma.id_igdb).FirstOrDefault();
                        if (lancamento == null)
                        {
                            lancamento = dados.ReleaseDates.Where(r => r.Region == 8).Where(r => r.Platform == plataforma.id_igdb).FirstOrDefault();
                        }
                        if (lancamento == null)
                        {
                            lancamento = dados.ReleaseDates.Where(r => r.Region == 2).Where(r => r.Platform == plataforma.id_igdb).FirstOrDefault();
                        }
                        if (lancamento == null)
                        {
                            if (plataforma.id != 7)
                            {
                                lancamento = dados.ReleaseDates.Where(r => r.Region == 8).Where(r => r.Platform == 45).FirstOrDefault();
                                if (lancamento == null)
                                {
                                    lancamento = dados.ReleaseDates.Where(r => r.Region == 2).Where(r => r.Platform == 45).FirstOrDefault();
                                }
                            }
                        }
                    }
                    if (lancamento != null)
                    {
                        if (lancamento.Date != null)
                        {
                            DateTime data = new DateTime(1970, 1, 1, 0, 0, 0).AddMilliseconds(Convert.ToDouble(Convert.ToDouble(lancamento.Date)));
                            g.release_date    = data;
                            db.Entry(g).State = EntityState.Modified;
                        }
                    }
                }
                catch (Exception ex) {
                    Console.Write(jogo.name + " " + ex.Message);
                }
            }
            db.SaveChanges();
        }
示例#26
0
        public Load()
        {
            InitializeComponent();
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                /*try
                 * {*/
                SecondBase = new GamesEntities(openFileDialog1.FileName);
                SecondBase.Database.Connection.Open();
                if (!DBUpdater.checkDBVersion(SecondBase))
                {
                    return;
                }
                List <string> MyGamesNames = new List <string>();
                foreach (var g in Program.context.Games)
                {
                    MyGamesNames.Add(g.GetFullName().ToUpper());
                }
                foreach (var g in SecondBase.Games)
                {
                    if (!MyGamesNames.Contains(g.GetFullName().ToUpper()))
                    {
                        GamesToAdd.Add(g);
                    }
                }
                GamesToAdd = GamesToAdd.OrderBy(g => g.Name).ToList();
                TreeNode TN, TN1;
                foreach (var g in GamesToAdd)
                {
                    if (g.Name == "Rebellion")
                    {
                        g.Name.ToString();
                    }
                    if (g.OriginalGame != null)
                    {
                        if (g.OriginalGame.OriginalGame != null)
                        {
                            TN = TreeNodeFinderRecursiv(win7StyleTreeView1.Nodes, g.OriginalGame.OriginalGame);
                            if (TN == null)
                            {
                                TN     = win7StyleTreeView1.Nodes.Add(g.OriginalGame.OriginalGame.Name);
                                TN.Tag = g.OriginalGame.OriginalGame;
                                if (Program.context.Games.FirstOrDefault(g1 => g1.Name == g.OriginalGame.OriginalGame.Name) != null)
                                {
                                    TN.Checked = true;
                                }
                            }
                            TN1 = TreeNodeFinderRecursiv(TN.Nodes, g.OriginalGame);
                            if (TN1 == null)
                            {
                                TN1     = TN.Nodes.Add(g.OriginalGame.Name);
                                TN1.Tag = g.OriginalGame;
                                if (Program.context.Games.FirstOrDefault(g1 => g1.Name == g.OriginalGame.Name) != null)
                                {
                                    TN1.Checked = true;
                                }
                            }
                            TN = TN1;
                        }
                        else
                        {
                            TN = TreeNodeFinderRecursiv(win7StyleTreeView1.Nodes, g.OriginalGame);
                            if (TN == null)
                            {
                                TN     = win7StyleTreeView1.Nodes.Add(g.OriginalGame.Name);
                                TN.Tag = g.OriginalGame;
                                if (Program.context.Games.FirstOrDefault(g1 => g1.Name == g.OriginalGame.Name) != null)
                                {
                                    TN.Checked = true;
                                }
                            }
                        }
                        if (TreeNodeFinderRecursiv(TN.Nodes, g) == null)
                        {
                            TN     = TN.Nodes.Add(g.Name);
                            TN.Tag = g;
                        }
                    }
                    else
                    {
                        if (TreeNodeFinderRecursiv(win7StyleTreeView1.Nodes, g) == null)
                        {
                            TN     = win7StyleTreeView1.Nodes.Add(g.Name);
                            TN.Tag = g;
                        }
                    }
                }
                GamesToAdd = new List <Games>();

                /*}
                 * catch(Exception ex)
                 * {
                 *      MessageBox.Show("Не удалось открыть файл.\n"+ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 * }*/
            }
        }
示例#27
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            var ok = true;

            //var m = new System.Threading.Mutex(true, "YourNameHere", out ok);//Проверяем не запущена ли ещё одна копия программы
            if (!ok)            //Если запущена, то выдаём ошибку и закрываем программу.
            {
                MessageBox.Show("Другая копия программы уже запущена.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData != null)
            {
                args = AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData;
            }
            //MessageBox.Show(Environment.Version.Build.ToString());
            if (Settings.Default.FirstRun)                   //Проверяем установлен ли флаг 1-ого запуска программы в Settings-файле
            {
                var wiz = new Wizard(args);                  //Создаём форму Мастера настройки
                if (wiz.ShowDialog() == DialogResult.Cancel) //Открываем диалог работы с мастером и ждём его завершения
                {
                    return;                                  //Если диалог завершился отменой, выходим из программы
                }
                wiz.Dispose();                               //Освобождаем ресурсы диалога, т.к. он нам больше не нужен
            }
            var s = new SplashScreen("Resources/gws_landing_hero.png");

            s.Show(false, true);
            try
            {
                if (args.Length >= 1)
                {
                    if (args[0] == "active")
                    {
                        context     = new GamesEntities(Settings.Default.DefaultConStr);                    //Создаём новый контекст базы данных, используя подключение по умолчанию из файла настроек
                        CurrentBase = Settings.Default.DefaultConStr;
                    }
                    else
                    {
                        context     = new GamesEntities(args[0]);
                        CurrentBase = args[0];
                    }
                }
                else
                {
                    context     = new GamesEntities(Settings.Default.DefaultConStr);                //Создаём новый контекст базы данных, используя подключение по умолчанию из файла настроек
                    CurrentBase = Settings.Default.DefaultConStr;
                }
                //Database.SetInitializer(new MigrateDatabaseToLatestVersion<GamesEntities, Migrations.Configuration>());
                if (Settings.Default.NewBase)                        //Если стоит флаг новой базы, то
                {
                    if (File.Exists(Settings.Default.DefaultConStr)) //Проверяем существует ли файл с указанным именем.
                    {
                        try
                        {
                            File.Delete(Settings.Default.DefaultConStr);                            //Пробуем удалить файл
                        }
                        catch
                        {
                            MessageBox.Show("Не удаётся перезаписать файл! Программа перезапустится, чтобы вы могли заного выбрать файл с играми.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            //Если удалить не удаётся, выводим сообщение об ошибке
                            Settings.Default.FirstRun = true;  //Устанавливаем флаг первого запуска, чтобы пользователь мог повторно создать базу.
                            Settings.Default.Save();           //Сохраняем файл настроек
                            Application.Restart();             //Перезапускаем программу
                            return;                            //Выходим из текущего экземпляра программы
                        }
                    }
                    context.Database.Create();                    //Создаём базу данных. Данный метод создаст файл базы данных в указанном месте.
                    context.Database.ExecuteSqlCommand(string.Format("INSERT INTO GLDBVersion (ID_V, Version) VALUES (1,{0});", Settings.Default.DatabaseVersion));
                    Settings.Default.NewBase = false;
                    Settings.Default.Save();
                }
                context.Database.Connection.Open();                //Открываем соединение с базой
            }
            catch (Exception ex1)
            {            //Если соединение с базой по умолчанию не удалось установить, то выводим следующий диалог
                var DR = MessageBox.Show(string.Format("Не удаётся подключиться к базе по умолчанию ({0}). {1} Попытаться создать новую базу?\nИли нажмите \"Нет\" чтобы открыть другой файл базы данных.", Settings.Default.DefaultConStr, ex1.Message), "Ошибка открытия", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
                //Предлагаем пользователию либо создать файл базы данны, либо открыть другую базу, или вообще выйти из программы
                switch (DR)                                          //Перебираем результат диалога
                {
                case DialogResult.Yes:                               //Если пользователь нажал Да
                    if (File.Exists(Settings.Default.DefaultConStr)) //Проверяем существует ли файл с указанным именем.
                    {
                        try
                        {
                            File.Delete(Settings.Default.DefaultConStr);                                    //Пробуем удалить файл
                        }
                        catch
                        {
                            MessageBox.Show("Не удаётся перезаписать файл! Программа перезапустится, чтобы вы могли заного выбрать файл с играми.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            //Если удалить не удаётся, выводим сообщение об ошибке
                            Settings.Default.FirstRun = true;          //Устанавливаем флаг первого запуска, чтобы пользователь мог повторно создать базу.
                            Settings.Default.Save();                   //Сохраняем файл настроек
                            Application.Restart();                     //Перезапускаем программу
                            return;                                    //Выходим из текущего экземпляра программы
                        }
                    }
                    context.Database.Create();                            //Создаём базу данных
                    context.Database.ExecuteSqlCommand(string.Format("INSERT INTO GLDBVersion (ID_V, Version) VALUES (1,{0});", Settings.Default.DatabaseVersion));
                    break;

                case DialogResult.No:                        //Если пользователь нажал Нет
                    var dial = new OpenFileDialog
                    {
                        Title    = "Выберите файл базы данных",
                        FileName = "MyGames.gdb",
                        Filter   = "База игр (*.gdb)|*.gdb"
                    };                                              //Создаём диалог открытия файла
                    if (dial.ShowDialog() == DialogResult.OK)       //Показываем диалог и проверяем результат
                    {
                        context = new GamesEntities(dial.FileName); //Создаём контекст базы данных с выбранным файлом
                        try
                        {
                            context.Database.Connection.Open();                                    //Пробуем установить соединение
                            CurrentBase = dial.FileName;
                            if (MessageBox.Show("Вы хотите, чтобы эта база стала базой по умолчанию?", "База по умолчанию", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                            {
                                Settings.Default.DefaultConStr = dial.FileName;
                                Settings.Default.Save();
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(string.Format("Произошла ошибка. Свяжитесь с автором.\n{0}", ex.Message)); //Если соединение установить не удалось, показываем ошибку.
                            return;                                                                                    //Выходим из программы
                        }
                    }
                    else
                    {
                        return;                                //Если пользователь отказался выбирать базу, то выходим из программы
                    }
                    break;

                case DialogResult.Cancel:              //Если пользователь отказался создавать или открывать базу
                    return;                            //то выходим из программы
                }
            }
            try
            {
                if (!DBUpdater.checkDBVersion(context))
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("{0}{1}", ex.Message, ex.InnerException != null ? "\n" + ex.InnerException.Message : null),
                                "Ошибка",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                return;
            }
            s.Close(new TimeSpan(0, 0, 0, 0, 500));
            Application.Run(new GamesForm());            //Запускаем главную форму
            //GC.KeepAlive(m);//Нужно для проверки уже запущенной копии
        }
示例#28
0
        public ActionResult Dashboard()
        {
            using (var _Entity = new GamesEntities())
            {
                Rauf_Gaming.Models.Dashboard dashboard = new Dashboard();

                dashboard.Orders = _Entity.Orders.ToList().Count;
                dashboard.Ps4New = _Entity.ProductV1.Where(p => p.Type == "Console" &&
                                                           p.Category == "PlayStation" && p.Condition == "New").ToList().Count();
                dashboard.Ps4Used = _Entity.ProductV1.Where(p => p.Type == "Console" &&
                                                            p.Category == "PlayStation" && p.Condition == "Used").ToList().Count();

                dashboard.XBoxNew = _Entity.ProductV1.Where(p => p.Type == "Console" &&
                                                            p.Category == "XBOX" && p.Condition == "New").ToList().Count();

                dashboard.XBoxUsed = _Entity.ProductV1.Where(p => p.Type == "Console" &&
                                                             p.Category == "XBOX" && p.Condition == "Used").ToList().Count();

                dashboard.NintendoNew = _Entity.ProductV1.Where(p => p.Type == "Console" &&
                                                                p.Category == "Nintendo" && p.Condition == "New").ToList().Count();

                dashboard.NintendoUsed = _Entity.ProductV1.Where(p => p.Type == "Console" &&
                                                                 p.Category == "Nintendo" && p.Condition == "Used").ToList().Count();

                dashboard.Ps4NewGames = _Entity.ProductV1.Where(p => p.Type == "Game" &&
                                                                p.Platform.Contains("Ps") && p.Condition == "New").ToList().Count();

                dashboard.Ps4UsedGames = _Entity.ProductV1.Where(p => p.Type == "Game" &&
                                                                 p.Platform.Contains("Ps") && p.Condition == "Used").ToList().Count();

                dashboard.XBoxNew = _Entity.ProductV1.Where(p => p.Type == "Game" &&
                                                            p.Platform.Contains("XBox") && p.Condition == "New").ToList().Count();

                dashboard.XBoxUsed = _Entity.ProductV1.Where(p => p.Type == "Game" &&
                                                             p.Platform.Contains("XBox") && p.Condition == "Used").ToList().Count();

                dashboard.NintendoNewGames = _Entity.ProductV1.Where(p => p.Type == "Game" &&
                                                                     p.Platform.Contains("Nintendo") && p.Condition == "New").ToList().Count();

                dashboard.NintendoUsedGames = _Entity.ProductV1.Where(p => p.Type == "Game" &&
                                                                      p.Platform.Contains("Nintendo") && p.Condition == "Used").ToList().Count();
                dashboard.VR = _Entity.ProductV1.Where(p => p.Type == "Acc" &&
                                                       p.Category == "VR").ToList().Count();
                dashboard.TV = _Entity.ProductV1.Where(p => p.Type == "Acc" &&
                                                       p.Category == "TV").ToList().Count();
                dashboard.HeadSet = _Entity.ProductV1.Where(p => p.Type == "Acc" &&
                                                            p.Category == "Headsets").ToList().Count();
                dashboard.Mouse = _Entity.ProductV1.Where(p => p.Type == "Acc" &&
                                                          p.Category == "Mouse").ToList().Count();
                dashboard.Keyboard = _Entity.ProductV1.Where(p => p.Type == "Acc" &&
                                                             p.Category == "Keyboards").ToList().Count();
                dashboard.JoyStick = _Entity.ProductV1.Where(p => p.Type == "Acc" &&
                                                             p.Category == "Joysticks").ToList().Count();
                dashboard.Speaker = _Entity.ProductV1.Where(p => p.Type == "Acc" &&
                                                            p.Category == "Speakers").ToList().Count();
                dashboard.Camera = _Entity.ProductV1.Where(p => p.Type == "Acc" &&
                                                           p.Category == "Cameras").ToList().Count();


                return(View(dashboard));
            }
        }
示例#29
0
 public BaseRepository()
 {
     db = new GamesEntities();
 }
示例#30
0
        public void AtualizarTudoIgdb()
        {
            GamesEntities db   = new GamesEntities();
            IgdbService   igdb = new IgdbService();
            DeveloperPublisherRepository developerPublisherRepository = new DeveloperPublisherRepository();
            GenreRepository genreRepository = new GenreRepository();

            var lista = db.game;

            foreach (var game in lista)
            {
                if (game.id_igdb != null)
                {
                    DadosGameResponse dados = igdb.DadosJogo((int)game.id_igdb).FirstOrDefault();
                    game.summary = dados.Summary;
                    if (dados.Developers != null)
                    {
                        foreach (var dev in dados.Developers)
                        {
                            var id_dev = developerPublisherRepository.GetIdByIgdb(dev, igdb.DadosDeveloperPublisher(new int[] { dev }).FirstOrDefault().Name);
                            var devs   = db.game_developerPublisher.Where(g => g.id_game == game.id && g.id_developerPublisher == id_dev && g.tipo == 1).Any();
                            if (!devs)
                            {
                                game.game_developerPublisher.Add(new game_developerPublisher {
                                    id_developerPublisher = id_dev, id_game = game.id, tipo = 1
                                });
                            }
                        }
                    }
                    if (dados.Publishers != null)
                    {
                        foreach (var pub in dados.Publishers)
                        {
                            var id_pub = developerPublisherRepository.GetIdByIgdb(pub, igdb.DadosDeveloperPublisher(new int[] { pub }).FirstOrDefault().Name);
                            var pubs   = db.game_developerPublisher.Where(g => g.id_game == game.id && g.id_developerPublisher == id_pub && g.tipo == 2).Any();
                            if (!pubs)
                            {
                                game.game_developerPublisher.Add(new game_developerPublisher {
                                    id_developerPublisher = id_pub, id_game = game.id, tipo = 2
                                });
                            }
                        }
                    }
                    if (dados.Genres != null)
                    {
                        foreach (var genre in dados.Genres)
                        {
                            var id_genre = genreRepository.GetIdByIgdb(genre, igdb.DadosGenre(new int[] { genre }).FirstOrDefault().Name);
                            var genres   = db.game_genre.Where(g => g.id_game == game.id && g.id_genre == id_genre).Any();
                            if (!genres)
                            {
                                game.game_genre.Add(new game_genre {
                                    id_genre = id_genre, id_game = game.id
                                });
                            }
                        }
                    }
                }
            }
            db.SaveChanges();
        }