예제 #1
0
        public void dodajGre(Gry g)
        {
            Gry_model gm = new Gry_model();

            gm.Gry.Add(g);
            gm.SaveChanges();
        }
예제 #2
0
        public void dodajGre(Gry g)
        {
            Gry_model gm = new Gry_model();

            gm.Gry.Add(g);
            try
            {
                gm.SaveChanges();
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    System.Diagnostics.Debug.WriteLine(@"Entity of type ""{0}"" in state ""{1}"" 
                   has the following validation errors:",
                                                       eve.Entry.Entity.GetType().Name,
                                                       eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        System.Diagnostics.Debug.WriteLine(@"- Property: ""{0}"", Error: ""{1}""",
                                                           ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }
            catch (DbUpdateException ex) {
                Console.WriteLine(ex.Message);
            }
        }
예제 #3
0
        public void edytujGre(Gry g)
        {
            Gry_model gm    = new Gry_model();
            var       query = (from gr in gm.Gry
                               where gr.Id == g.Id
                               select gr).First();

            query.Tytul        = g.Tytul;
            query.Producent_Id = g.Producent_Id;
            query.Gatunek_Id   = g.Gatunek_Id;
            query.Rok_wydania  = g.Rok_wydania;
            query.Kraj         = g.Kraj;
            query.Platforma    = g.Platforma;
            query.Ocena_Id     = g.Ocena_Id;
            gm.SaveChanges();
        }