コード例 #1
0
        public static bool Guardar(Entidades.Materias nueva)
        {
            bool retorno = false;

            using (var db = new DataDb())
            {
                try
                {
                    if (Buscar(nueva.MateriaId) == null)
                    {
                        db.MateriaDb.Add(nueva);
                        db.SaveChanges();
                        retorno = true;
                    }
                    else
                    {
                        db.Entry(nueva).State = EntityState.Unchanged;
                        retorno = true;
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(retorno);
        }
コード例 #2
0
        public static bool Guardar(Entidades.Estudiantes n)
        {
            bool retono = false;

            using (var db = new DataDb())
            {
                try
                {
                    foreach (var g in n.MateriaList)
                    {
                        db.Entry(g).State = System.Data.Entity.EntityState.Unchanged;
                    }

                    if (Buscar(n.EstudianteId) == null)
                    {
                        db.EstudiantesDb.Add(n);
                        db.SaveChanges();
                        retono = true;
                    }
                    else
                    {
                        db.Entry(n).State = System.Data.Entity.EntityState.Unchanged;
                        retono            = true;
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(retono);
        }
コード例 #3
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, DataDb db, Producer producer)
        {
            db.Database.EnsureCreated();
            producer.Init();

            app.UseCors(c => c.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin());

            app.UseSapphireDb();
        }
コード例 #4
0
        //public function to make a list of memebers from the database
        public DataDb MakeList()
        {
            DataDb mlist = new DataDb();

            mlist.DishList    = new List <Menu>();
            mlist.MembersList = new List <Member>();
            mlist.MembersList = members.Members.ToList <Member>();
            return(mlist);
        }
コード例 #5
0
 public static bool Eliminar(Entidades.Estudiantes id)
 {
     using (var db = new DataDb())
     {
         try
         {
             db.Entry(id).State = System.Data.Entity.EntityState.Deleted;
             return(true);
         }
         catch (Exception)
         {
             throw;
         }
     }
 }
コード例 #6
0
        public PgLibrary(
            DataDb dataDb,
            SettingsManager settingsManager,
            PageNavigator pageNavigator
            )
        {
            this.dataDb          = dataDb;
            this.settingsManager = settingsManager;
            this.pageNavigator   = pageNavigator;
            InitializeComponent();

            SpDelete.SetBinding(VisibilityHelper.IsVisibleProperty, new Binding()
            {
                Path   = new(nameof(IsCheckActive), null),
                Source = this
            });
コード例 #7
0
 public static Entidades.Estudiantes Buscar(int id)
 {
     Entidades.Estudiantes nuevo;
     using (var db = new DataDb())
     {
         try
         {
             nuevo = db.EstudiantesDb.Find(id);
         }
         catch (Exception)
         {
             throw;
         }
         return(nuevo);
     }
 }
コード例 #8
0
        public static List <Entidades.Materias> GetListodo()
        {
            List <Entidades.Materias> lista = new List <Entidades.Materias>();

            using (var db = new DataDb())
            {
                try
                {
                    lista = db.MateriaDb.ToList();
                }
                catch (Exception)
                {
                    throw;
                }
                return(lista);
            }
        }
コード例 #9
0
        public static Entidades.Materias Buscar(int id)
        {
            var nuevo = new Entidades.Materias();

            using (var db = new DataDb())
            {
                try
                {
                    nuevo = db.MateriaDb.Find(id);
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(nuevo);
        }
コード例 #10
0
        public static List <Entidades.Estudiantes> GetListNombre(string nombre)
        {
            List <Entidades.Estudiantes> lista = new List <Entidades.Estudiantes>();

            using (var db = new DataDb())
            {
                try
                {
                    lista = db.EstudiantesDb.Where(p => p.Nombre == nombre).ToList();
                }
                catch (Exception)
                {
                    throw;
                }
                return(lista);
            }
        }
コード例 #11
0
        //action to add a new dish to the menu according to the form
        public ActionResult AddDish(DataDb obj)
        {
            var data = menu.Dishes.Where(x => x.Name == obj.Dish.Name).ToList <Menu>();

            if (data.Count != 0 && data[0].Name == obj.Dish.Name)
            {
                return(Json(new { success = false }, JsonRequestBehavior.AllowGet));
            }
            Menu mem = new Menu();

            mem.Category = obj.Dish.Category;
            mem.Name     = obj.Dish.Name;
            mem.Price    = obj.Dish.Price;
            menu.Dishes.Add(mem);
            menu.SaveChanges();
            return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
        }
コード例 #12
0
        private void TransferToDatabase()
        {
            DataDb db = _serviceProvider.CreateScope().ServiceProvider.GetService <DataDb>();

            List <DataEntry> entriesGrouped = DataEntries
                                              .GroupBy(e => new { e.ClientId, Time = e.Time.Round(TimeSpan.FromSeconds(1)) })
                                              .Select(grouping =>
            {
                return(new DataEntry()
                {
                    Time = grouping.Key.Time,
                    ClientId = grouping.Key.ClientId,
                    AverageDiff = grouping.Average(v => v.AverageDiff)
                });
            })
                                              .ToList();

            db.Entries.AddRange(entriesGrouped);
            db.SaveChanges();
            DataEntries.Clear();
            _logger.LogInformation($"Storing data to database");
        }
コード例 #13
0
 internal ViajeController(DataDb data)
 {
     Data = data;
 }
コード例 #14
0
 public SettingsManager(DataDb dataDb)
 {
     this.dataDb = dataDb;
 }