Beispiel #1
0
        public ActionResult Create([Bind(Include = "ID,Name,Phone,Email,Address")] Supplier supplier)
        {
            if (ModelState.IsValid)
            {
                db.Suppliers.Add(supplier);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(supplier));
        }
Beispiel #2
0
        public ActionResult Create([Bind(Include = "ID,Name,Email,NationalID,Phone,Address,Title,Salary,ReportsTo")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                db.Employees.Add(employee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ReportsTo = new SelectList(db.Employees, "ID", "Name", employee.ReportsTo);
            return(View(employee));
        }
Beispiel #3
0
 private void delGameToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (
         MessageBox.Show(
             string.Format("Вы действительно хотите удалить дополнение {0} из базы?", ((Games)gamesBindingSource.Current).Name), "Удаление",
             MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
     {
         return;
     }
     _context.Games.Remove((Games)gamesBindingSource.Current);
     _context.SaveChanges();
     Changefilter();
     UpdateView();
 }
Beispiel #4
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."));
            }
        }
        public ActionResult Create(Game game)
        {
            if (ModelState.IsValid)
            {
                //Save in Object to save into DB
                string _fileName   = Path.GetFileNameWithoutExtension(game.FilePhoto.FileName);
                string _Extenstion = Path.GetExtension(game.FilePhoto.FileName);
                _fileName  = game.ID.ToString() + _Extenstion;
                game.Image = _fileName;
                _fileName  = Path.Combine(Server.MapPath("~/Upload/Images/") + _fileName);
                game.FilePhoto.SaveAs(_fileName);
                db.Games.Add(game);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(View(game));
        }
Beispiel #6
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"));
        }
Beispiel #7
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"));
     }
 }
Beispiel #8
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);
            }
        }
 public ActionResult Create(Xbox xb)
 {
     try
     {
         var data = db.Entry(xb).State = System.Data.Entity.EntityState.Added;
         int a    = db.SaveChanges();
         if (a > 0)
         {
             return(RedirectToAction("Index"));
         }
         else
         {
             return(View(data));
         }
     }
     catch
     {
         return(View());
     }
 }
Beispiel #10
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));
     }
 }
Beispiel #11
0
        public ActionResult Create(PS4 ps)
        {
            try
            {
                // TODO: Add insert logic here

                var data = db.Entry(ps).State = System.Data.Entity.EntityState.Added;
                int a    = db.SaveChanges();
                if (a > 0)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View(data));
                }
            }
            catch
            {
                return(View());
            }
        }
Beispiel #12
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();
        }
Beispiel #13
0
        private void AddBut_Click(object sender, EventArgs e)
        {
            if (nameTextBox.Text == "")
            {
                rectangleShape1.Visible = true;
                MessageBox.Show("Введите хотя бы имя игры!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            Cursor = Cursors.WaitCursor;

            AddingGame.Name          = AddingGame.Name.Trim();
            AddingGame.Original_Name = !OriginalNameEn.Checked ? null : AddingGame.Original_Name.Trim();

            if (posterPictureBox.Image != null)
            {
                var stream = new MemoryStream();
                posterPictureBox.Image.Save(stream, posterPictureBox.Image.RawFormat);
                AddingGame.Poster = stream.GetBuffer();
            }
            else
            {
                AddingGame.Poster = null;
            }

            AddingGame.Localisation_Type = comboBox4.SelectedIndex;
            AddingGame.Status_complite   = comboBox5.SelectedIndex;

            if (AddingGame.TypeContent ?? false)
            {
                if (numericUpDown1.Value == 0)
                {
                    AddingGame.Kol_updates = 0;
                }
                AddingGame.Platforms = new List <Platforms>();
                foreach (Platforms p in PlatformsList.CheckedItems)
                {
                    AddingGame.Platforms.Add(_context.Platforms.Find(p.ID_Platform));
                }

                AddingGame.Online_protections = new List <Online_protections>();
                foreach (Online_protections p in OnlineProtectionsList.CheckedItems)
                {
                    AddingGame.Online_protections.Add(_context.Online_protections.Find(p.ID_Protect));
                }
            }

            if (AddingGame.ID_Developer == 0)
            {
                AddingGame.ID_Developer = null;
            }

            if (AddingGame.ID_Publisher == 0)
            {
                AddingGame.ID_Publisher = null;
            }

            if (AddingGame.ID_RF_Distributor == 0)
            {
                AddingGame.ID_RF_Distributor = null;
            }

            if (AddingGame.ID_Ser == 0)
            {
                AddingGame.ID_Ser = null;
            }

            _context.Games.Add(AddingGame);
            try
            {
                _context.SaveChanges();
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Произошла ошибка:\n{0}\n{1}", ex.Message, (ex.InnerException != null ? ex.InnerException.Message : ""))
                                , "Ошибка"
                                , MessageBoxButtons.OK
                                , MessageBoxIcon.Error);
                Cursor = Cursors.Default;
                _context.Games.Remove(AddingGame);
                return;
            }
            Cursor       = Cursors.Default;
            Compl        = true;
            DialogResult = DialogResult.OK;
        }
Beispiel #14
0
        private void AddBut_Click(object sender, EventArgs e)
        {
            if (nameTextBox.Text == "")
            {
                rectangleShape1.Visible = true;
                MessageBox.Show("Введите имя сборника!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (listBox1.Items.Count <= 0)
            {
                MessageBox.Show("Не имеет смысла добавлять сборник без игр.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Cursor                   = Cursors.WaitCursor;
            AddingGame.Name          = AddingGame.Name.Trim();
            AddingGame.Original_Name = !OriginalNameEn.Checked ? null : AddingGame.Original_Name.Trim();

            if (posterPictureBox.Image != null)
            {
                var stream = new MemoryStream();
                posterPictureBox.Image.Save(stream, posterPictureBox.Image.RawFormat);
                AddingGame.Poster = stream.GetBuffer();
            }
            else
            {
                AddingGame.Poster = null;
            }

            AddingGame.Localisation_Type = -1;

            AddingGame.Platforms = new List <Platforms>();
            foreach (Platforms p in PlatformsList.CheckedItems)
            {
                AddingGame.Platforms.Add(p);
            }

            AddingGame.Online_protections = new List <Online_protections>();
            foreach (Online_protections p in OnlineProtectionsList.CheckedItems)
            {
                AddingGame.Online_protections.Add(p);
            }

            if (AddingGame.ID_Publisher == 0)
            {
                AddingGame.ID_Publisher = null;
            }

            if (AddingGame.ID_RF_Distributor == 0)
            {
                AddingGame.ID_RF_Distributor = null;
            }

            AddingGame.GamesInCollect = new List <Games>();
            foreach (Games g in listBox1.Items)
            {
                AddingGame.GamesInCollect.Add(g);
            }

            _context.Games.Add(AddingGame);
            try
            {
                _context.SaveChanges();
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Произошла ошибка:\n{0}\n{1}", ex.Message, (ex.InnerException != null ? ex.InnerException.Message : ""))
                                , "Ошибка"
                                , MessageBoxButtons.OK
                                , MessageBoxIcon.Error);
                _context.Games.Remove(AddingGame);
                Cursor = Cursors.Default;
                return;
            }
            Cursor       = Cursors.Default;
            Compl        = true;
            DialogResult = DialogResult.OK;
        }
Beispiel #15
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();
        }
Beispiel #16
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();
        }