Ejemplo n.º 1
0
        public void SaveCars(int id, string name, string color, int year)
        {
            using (var context = new localDbEntities())
            {
                context.CarsDbs.Add(new CarsDb()
                {
                    Id    = id,
                    Name  = name,
                    Color = color,
                    Year  = year
                });

                context.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        public void UpdateCars(int id, string name, string color, int year)
        {
            using (var context = new localDbEntities())
            {
                var carIdentity = context.CarsDbs.Where(c => c.Id == id).FirstOrDefault <CarsDb>();

                if (carIdentity != null)
                {
                    carIdentity.Name  = name;
                    carIdentity.Color = color;
                    carIdentity.Year  = year;

                    context.SaveChanges();
                }
            }
        }