예제 #1
0
        public async Task <IActionResult> UpdateVehicle([FromBody] Vehicle vehicle)
        {
            using (var context = new GlobalDbContext())
            {
                context.Vehicles.Update(vehicle);
                await context.SaveChangesAsync();

                return(Ok());
            }
        }
예제 #2
0
        public async Task <IActionResult> UpdateCustomer([FromBody] Customer customer)
        {
            using (var context = new GlobalDbContext())
            {
                context.Customers.Update(customer);
                await context.SaveChangesAsync();

                return(Ok());
            }
        }
예제 #3
0
        public void Init()
        {
            globalDbContext = new GlobalDbContext();

            // 预加载
            Task.Run(() =>
            {
                globalDbContext.Accounts.Load();
                status = 1;
            });
        }
예제 #4
0
        public async Task Invoke(HttpContext httpContext, GlobalDbContext dbContext)
        {
            var tenantGuid = httpContext.Request.Headers["X-Tenant-Guid"].FirstOrDefault();

            if (!string.IsNullOrEmpty(tenantGuid))
            {
                var tenant = dbContext.Tenants.FirstOrDefault(t => t.Guid.ToString() == tenantGuid);
                httpContext.Items["TENANT"] = tenant;
            }

            await _next.Invoke(httpContext);
        }
 public void Write(string lugar_examen, int num_componentes)
 {
     using (GlobalDbContext dbContext = new GlobalDbContext())
     {
         Tribunal tribunal = new Tribunal()
         {
             Lugar_Examen    = lugar_examen,
             Num_Componentes = num_componentes
         };
         dbContext.Add(tribunal);
         dbContext.SaveChanges();
     }
 }
 public void Write(int dni, string nombre)
 {
     using (GlobalDbContext dbContext = new GlobalDbContext())
     {
         Alumno alumno = new Alumno()
         {
             Dni    = dni,
             Nombre = nombre
         };
         dbContext.Add(alumno);
         dbContext.SaveChanges();
     }
 }
예제 #7
0
 public void Write(string nombre_grupo, int num_componente)
 {
     using (GlobalDbContext dbContext = new GlobalDbContext())
     {
         Grupo grupo = new Grupo()
         {
             Nombre_grupo   = nombre_grupo,
             Num_componente = num_componente
         };
         dbContext.Add(grupo);
         dbContext.SaveChanges();
     }
 }
        public async Task Invoke(HttpContext httpContext, GlobalDbContext globalDbContext)
        {
            var tenantId = httpContext.Request.Headers["X-Tenant-Id"].FirstOrDefault();

            if (!string.IsNullOrWhiteSpace(tenantId))
            {
                var tenant = await globalDbContext.Tenants.SingleOrDefaultAsync(x => x.Id.ToString() == tenantId);

                httpContext.Items["TENANT"] = tenant;
            }

            await _next.Invoke(httpContext);
        }
예제 #9
0
 public void Write(string tema, string fecha)
 {
     using (GlobalDbContext dbContext = new GlobalDbContext())
     {
         TFC tfc = new TFC()
         {
             Tema  = tema,
             Fecha = fecha
         };
         dbContext.Add(tfc);
         dbContext.SaveChanges();
     }
 }
예제 #10
0
 public void Delete(int dni)
 {
     using (GlobalDbContext dbContext = new GlobalDbContext())
     {
         Profesor profesor = dbContext.Profesores(true)
                             .Where(s => s.DNI == dni)
                             .FirstOrDefault();
         if (profesor != null)
         {
             dbContext.Remove(profesor);
             dbContext.SaveChanges();
         }
     }
 }
예제 #11
0
        public async Task <IActionResult> DeleteVehicle([FromQuery] int id)
        {
            using (var context = new GlobalDbContext())
            {
                var vehicle = await context.Vehicles.FirstOrDefaultAsync(x => x.Id == id);

                if (vehicle != null)
                {
                    context.Vehicles.Remove(vehicle);
                    await context.SaveChangesAsync();
                }
                return(Ok());
            }
        }
예제 #12
0
        public async Task <IActionResult> DeleteCustomer([FromQuery] int id)
        {
            using (var context = new GlobalDbContext())
            {
                var customer = await context.Customers.FirstOrDefaultAsync(x => x.Id == id);

                if (customer != null)
                {
                    context.Customers.Remove(customer);
                    await context.SaveChangesAsync();
                }
                return(Ok());
            }
        }
예제 #13
0
 public void Delete(int num_grupo)
 {
     using (GlobalDbContext dbContext = new GlobalDbContext())
     {
         Grupo grupo = dbContext.Grupos(true)
                       .Where(s => s.Num_grupo == num_grupo)
                       .FirstOrDefault();
         if (grupo != null)
         {
             dbContext.Remove(grupo);
             dbContext.SaveChanges();
         }
     }
 }
 public void Delete(int num)
 {
     using (GlobalDbContext dbContext = new GlobalDbContext())
     {
         Tribunal tribunal = dbContext.Tribunales(true)
                             .Where(s => s.Num == num)
                             .FirstOrDefault();
         if (tribunal != null)
         {
             dbContext.Remove(tribunal);
             dbContext.SaveChanges();
         }
     }
 }
예제 #15
0
 public void Write(int dni, string nombre, string domicilio)
 {
     using (GlobalDbContext dbContext = new GlobalDbContext())
     {
         Profesor profesor = new Profesor()
         {
             DNI       = dni,
             Nombre    = nombre,
             Domicilio = domicilio
         };
         dbContext.Add(profesor);
         dbContext.SaveChanges();
     }
 }
 public void Delete(int num_matricula)
 {
     using (GlobalDbContext dbContext = new GlobalDbContext())
     {
         Alumno alumno = dbContext.Alumnos(true)
                         .Where(s => s.Num_Matricula == num_matricula)
                         .FirstOrDefault();
         if (alumno != null)
         {
             dbContext.Remove(alumno);
             dbContext.SaveChanges();
         }
     }
 }
예제 #17
0
 public void Delete(int num_orden)
 {
     using (GlobalDbContext dbContext = new GlobalDbContext())
     {
         TFC tfc = dbContext.TFCs(true)
                   .Where(s => s.Num_orden == num_orden)
                   .FirstOrDefault();
         if (tfc != null)
         {
             dbContext.Remove(tfc);
             dbContext.SaveChanges();
         }
     }
 }
 public List <Tribunal> GetTribunales(string buscarText)
 {
     using (GlobalDbContext dbContext = new GlobalDbContext())
     {
         IQueryable <Tribunal> query = dbContext.Tribunales();
         if (!string.IsNullOrEmpty(buscarText))
         {
             query = query.Where(c =>
                                 c.Lugar_Examen.Contains(buscarText)
                                 );
         }
         query = query.OrderBy(tribunal => tribunal.Lugar_Examen);
         return(query.ToList());
     }
 }
예제 #19
0
        public List <Profesor> GetProfesores(string buscarText)
        {
            using (GlobalDbContext dbContext = new GlobalDbContext())
            {
                IQueryable <Profesor> query = dbContext.Profesores();
                if (!string.IsNullOrEmpty(buscarText))
                {
                    query = query.Where(c =>
                                        c.Nombre.Contains(buscarText)
                                        );
                }

                query = query.OrderBy(profesor => profesor.Nombre);
                return(query.ToList());
            }
        }
예제 #20
0
        public void Update(int num_orden, string tema, string fecha)
        {
            using (GlobalDbContext dbContext = new GlobalDbContext())
            {
                TFC tfc = dbContext.TFCs(true)
                          .Where(s => s.Num_orden == num_orden)
                          .FirstOrDefault();
                if (tfc != null)
                {
                    tfc.Tema  = tema;
                    tfc.Fecha = fecha;

                    dbContext.SaveChanges();
                }
            }
        }
        public void Update(int num, string lugar_examen, int num_componentes)
        {
            using (GlobalDbContext dbContext = new GlobalDbContext())
            {
                Tribunal tribunal = dbContext.Tribunales(true)
                                    .Where(s => s.Num == num)
                                    .FirstOrDefault();
                if (tribunal != null)
                {
                    tribunal.Lugar_Examen    = lugar_examen;
                    tribunal.Num_Componentes = num_componentes;

                    dbContext.SaveChanges();
                }
            }
        }
예제 #22
0
        public List <TFC> GetTFC(string buscarText)
        {
            using (GlobalDbContext dbContext = new GlobalDbContext())
            {
                IQueryable <TFC> query = dbContext.TFCs();
                if (!string.IsNullOrEmpty(buscarText))
                {
                    query = query.Where(c =>
                                        c.Tema.Contains(buscarText)
                                        );
                }

                query = query.OrderBy(tfc => tfc.Tema);
                return(query.ToList());
            }
        }
예제 #23
0
        public List <Grupo> GetGrupos(string buscarText)
        {
            using (GlobalDbContext dbContext = new GlobalDbContext())
            {
                IQueryable <Grupo> query = dbContext.Grupos();
                if (!string.IsNullOrEmpty(buscarText))
                {
                    query = query.Where(c =>
                                        c.Nombre_grupo.Contains(buscarText)
                                        );
                }

                query = query.OrderBy(grupo => grupo.Nombre_grupo);
                return(query.ToList());
            }
        }
        public void Update(int num_matricula, int dni, string nombre)
        {
            using (GlobalDbContext dbContext = new GlobalDbContext())
            {
                Alumno alumno = dbContext.Alumnos(true)
                                .Where(s => s.Num_Matricula == num_matricula)
                                .FirstOrDefault();
                if (alumno != null)
                {
                    alumno.Dni    = dni;
                    alumno.Nombre = nombre;

                    dbContext.SaveChanges();
                }
            }
        }
예제 #25
0
        public void Update(int num_grupo, string nombre_grupo, int num_componente)
        {
            using (GlobalDbContext dbContext = new GlobalDbContext())
            {
                Grupo grupo = dbContext.Grupos(true)
                              .Where(s => s.Num_grupo == num_grupo)
                              .FirstOrDefault();
                if (grupo != null)
                {
                    grupo.Nombre_grupo   = nombre_grupo;
                    grupo.Num_componente = num_componente;

                    dbContext.SaveChanges();
                }
            }
        }
예제 #26
0
        public async Task <IActionResult> GetVehicles()
        {
            try
            {
                await parallelism.WaitAsync();

                using (var context = new GlobalDbContext())
                {
                    return(Ok(context.Vehicles.ToList()));
                }
            }
            finally
            {
                parallelism.Release();
            }
        }
        public List <Alumno> GetAlumnos(string buscarText)
        {
            using (GlobalDbContext dbContext = new GlobalDbContext())
            {
                IQueryable <Alumno> query = dbContext.Alumnos();
                if (!string.IsNullOrEmpty(buscarText))
                {
                    query = query.Where(c =>
                                        c.Nombre.Contains(buscarText)
                                        );
                }

                query = query.OrderBy(alumno => alumno.Nombre);
                return(query.ToList());
            }
        }
예제 #28
0
        public void Update(int dni, string nombre, string domicilio)
        {
            using (GlobalDbContext dbContext = new GlobalDbContext())
            {
                Profesor profesor = dbContext.Profesores(true)
                                    .Where(s => s.DNI == dni)
                                    .FirstOrDefault();
                if (profesor != null)
                {
                    profesor.DNI       = dni;
                    profesor.Nombre    = nombre;
                    profesor.Domicilio = domicilio;

                    dbContext.SaveChanges();
                }
            }
        }
예제 #29
0
파일: Update.cs 프로젝트: PeterKneale/micro
 public Handler(GlobalDbContext db, IMapper map)
 {
     _db = db;
     _map = map;
 }
예제 #30
0
 public MovieStudioController(GlobalDbContext context)
 {
     _context = context;
 }