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); }
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); }
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(); }
//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); }
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; } } }
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 });
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); } }
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); } }
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); }
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); } }
//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)); }
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"); }
internal ViajeController(DataDb data) { Data = data; }
public SettingsManager(DataDb dataDb) { this.dataDb = dataDb; }