예제 #1
0
 public ActionResult Post([FromBody] TipoPlanillas tp)
 {
     try
     {
         _context.Add(tp);
         _context.SaveChanges();
         return(Ok());
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
예제 #2
0
        public async Task <IActionResult> GetTipoPlanillasByTipoPlanilla(String TipoPlanilla)
        {
            TipoPlanillas Items = new TipoPlanillas();

            try
            {
                Items = await _context.TipoPlanillas.Where(q => q.TipoPlanilla == TipoPlanilla).FirstOrDefaultAsync();
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                return(BadRequest($"Ocurrio un error:{ex.Message}"));
            }


            return(await Task.Run(() => Ok(Items)));
        }
예제 #3
0
        public async Task <ActionResult <TipoPlanillas> > Insert([FromBody] TipoPlanillas _TipoPlanillas)
        {
            TipoPlanillas _TipoPlanillasq = new TipoPlanillas();

            try
            {
                _TipoPlanillasq = _TipoPlanillas;
                _context.TipoPlanillas.Add(_TipoPlanillasq);
                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                return(BadRequest($"Ocurrio un error:{ex.Message}"));
            }

            return(await Task.Run(() => Ok(_TipoPlanillasq)));
        }
예제 #4
0
 public ActionResult Put(int id, [FromBody] TipoPlanillas tp)
 {
     try
     {
         if (id != tp.Id)
         {
             return(BadRequest());
         }
         _context.Entry(tp).State = EntityState.Modified;
         _context.Update(tp);
         _context.SaveChanges();
         return(Ok());
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
예제 #5
0
        public async Task <ActionResult <TipoPlanillas> > Update([FromBody] TipoPlanillas _TipoPlanillas)
        {
            TipoPlanillas _TipoPlanillasq = _TipoPlanillas;

            try
            {
                _TipoPlanillasq = await(from c in _context.TipoPlanillas
                                        .Where(q => q.IdTipoPlanilla == _TipoPlanillas.IdTipoPlanilla)
                                        select c
                                        ).FirstOrDefaultAsync();

                _context.Entry(_TipoPlanillasq).CurrentValues.SetValues((_TipoPlanillas));


                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                _logger.LogError($"Ocurrio un error: { ex.ToString() }");
                return(BadRequest($"Ocurrio un error:{ex.Message}"));
            }

            return(await Task.Run(() => Ok(_TipoPlanillasq)));
        }