Beispiel #1
0
 public async Task <ActionResult <VueloModel> > aPost(VueloModel payload)
 {
     using (var context = new VueloContext())
     {
         context.VueloM.Add(payload);
         await context.SaveChangesAsync();
     }
     return(Ok(payload));
 }
Beispiel #2
0
        public async Task <ActionResult <VueloModel> > aGet(int?id)
        {
            using (var context = new VueloContext())
            {
                if (id == null)
                {
                    var vuelovar = context.VueloM.ToList();
                    return(Ok(vuelovar));
                }
                var aw = await context.VueloM.FindAsync(id);

                return(NotFound(aw));
            }
        }
Beispiel #3
0
        public async Task <ActionResult <VueloModel> > aDel(int id)
        {
            using (var context = new VueloContext()){
                var aw = await context.VueloM.FindAsync(id);

                if (aw == null)
                {
                    return(NotFound());
                }

                context.VueloM.Remove(aw);
                await context.SaveChangesAsync();

                return(Ok(aw));
            }
        }
Beispiel #4
0
        public async Task <ActionResult <VueloModel> > aPut(int id, [FromBody] VueloModel payload) //el frombody es opcional
        {
            using (var context = new VueloContext())
            {
                var aw = await context.VueloM.FindAsync(id);

                if (aw == null)
                {
                    return(BadRequest("id not found"));
                }

                aw.source = payload.source;
                aw.dest   = payload.dest;
                //aw.aval = payload.aval;
                aw.status = payload.status;

                context.Update(aw);
                await context.SaveChangesAsync();

                return(Ok(aw));
            }
        }
 public ReservacionController(ReservacionContext context, VueloContext vuelo, ClienteContext cliente)
 {
     _context        = context;
     _Vuelocontext   = vuelo;
     _Clientecontext = cliente;
 }
Beispiel #6
0
 public VueloController(VueloContext context, EmpleadoContext empleadoContext)
 {
     _context         = context;
     _empleadoContext = empleadoContext;
 }