예제 #1
0
        public void Favorito([Bind("Id,CompradorId,VendedorId")] VendedorFavorito vendedorFavorito)
        {
            var id = _context.VendedorFavorito.FirstOrDefaultAsync(m => m.VendedorId == vendedorFavorito.VendedorId && m.CompradorId == vendedorFavorito.CompradorId).Result;

            if (id != null)
            {
                _context.VendedorFavorito.Remove(id);
            }
            else
            {
                _context.Add(vendedorFavorito);
            }
            _context.SaveChanges();
        }
예제 #2
0
 public static void Initialize(IServiceProvider serviceProvider)
 {
     using (var context = new UPBEatsContext(
                serviceProvider.GetRequiredService <
                    DbContextOptions <UPBEatsContext> >()))
     {
         // Buscando cualquier rol
         if (context.Rol.Any())
         {
             return;   // Ya se inicializó la BD
         }
         //Roles agregar
         context.Rol.AddRange(
             new Rol {
             Nombre = "Comprador"
         },
             new Rol {
             Nombre = "Vendedor"
         }
             );
         context.SaveChanges();
     }
 }