Exemplo n.º 1
0
        public async Task<IActionResult> PutTienda(int id, Tienda tienda)
        {
            if (id != tienda.Id)
            {
                return BadRequest();
            }

            _context.Entry(tienda).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TiendaExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return NoContent();
        }
        public async Task <IActionResult> PutPrices(string id, PricesDto prices)
        {
            if (id != prices.PricesId)
            {
                return(BadRequest());
            }

            _context.Entry(prices).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PricesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutOrderHistory(string id, OrderHistory orderHistory)
        {
            if (id != orderHistory.OrderHistoryId)
            {
                return(BadRequest());
            }

            _context.Entry(orderHistory).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OrderHistoryExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 4
0
        public async Task <ActionResult <Tarea> > create(Tarea item)
        {
            _context.Tareas.Add(item);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(getItem), new { cod_tarea = item.cod_tarea }, item));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> PutArticulo(int id, Articulo articulo)
        {
            if (id != articulo.Id)
            {
                return(BadRequest());
            }

            _context.Entry(articulo).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ArticuloExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 6
0
            public async Task <int> Handle(SeguimientoCreate request, CancellationToken cancellationToken)
            {
                var e = request.MapTo <seguimiento>();

                if (e.documentosemitidos <= 0)
                {
                    e.documentosemitidos = 1;
                }

                e.tipodocumentoid = request.tipodoc.ToString();
                e.fechaenvio      = DateTime.UtcNow - TimeSpan.FromHours(5);
                e.estadoenvio     = request.Estado.ToString();
                if ((e.nombrearchivo ?? "").Length > 150)
                {
                    e.nombrearchivo = (e.nombrearchivo ?? "").Substring(0, 150);
                }

                await _bdContext.seguimiento.AddAsync(e, cancellationToken);

                var valor = await _bdContext.SaveChangesAsync(cancellationToken);

                if (valor > 0)
                {
                    return(e.id);
                }

                throw new Exception("No se guardaron los cambios");
            }
Exemplo n.º 7
0
        public async Task <IActionResult> Incluir(string Nome)
        {
            try
            {
                var D = new Tb_Desenvolvedor();
                D.Nome = Nome;
                await _context.Tb_Desenvolvedores.AddAsync(D);

                await _context.SaveChangesAsync();

                return(StatusCode(200));
            }
            catch (Exception ex)
            {
                var errorId = Guid.NewGuid();
                _logger.LogError(ex, "ErrorId: {0}", errorId.ToString());
                return(StatusCode(500, new { ErrorId = errorId.ToString(), Mensagem = ex.Message }));
            }
        }
Exemplo n.º 8
0
        public async Task <IActionResult> Incluir(string Nome, string Desenvolvedores)
        {
            try
            {
                var P = new Tb_Projeto();
                P.InAtivo = true;
                P.Nome    = Nome;
                await _context.Tb_Projetos.AddAsync(P);

                await _context.SaveChangesAsync();

                int Proj_id = P.Id;
                if (Desenvolvedores != null)
                {
                    var DevsArray = Desenvolvedores.Split("/");
                    foreach (var item in DevsArray)
                    {
                        if (!String.IsNullOrEmpty(item))
                        {
                            var tbDev_proj = new Tb_Desenvolvedor_Projeto();
                            tbDev_proj.Tb_ProjetoId = Proj_id;
                            tbDev_proj.InAtivo      = true;

                            tbDev_proj.Tb_Desenvolvedor = _context.Tb_Desenvolvedores.FirstOrDefault(x => x.Nome == item);
                            if (tbDev_proj.Tb_Desenvolvedor != null)
                            {
                                tbDev_proj.Tb_DesenvolvedorId = tbDev_proj.Tb_Desenvolvedor.Id;
                                await _context.Tb_Desenvolvedores_Projetos.AddAsync(tbDev_proj);
                            }
                        }
                    }
                }
                await _context.SaveChangesAsync();

                return(StatusCode(200));
            }
            catch (Exception ex)
            {
                var errorId = Guid.NewGuid();
                _logger.LogError(ex, "ErrorId: {0}", errorId.ToString());
                return(StatusCode(500, new { ErrorId = errorId.ToString(), Mensagem = ex.Message }));
            }
        }
        public async Task <IActionResult> Incluir(string Desenv_Proj_Id, string DataInicio, string DataFim, string Hora)
        {
            try
            {
                var lh = new Tb_LancamentoHoras();
                lh.Tb_Desenvolvedor_ProjetoId = int.Parse(Desenv_Proj_Id);
                lh.DataInicio = DateTime.Parse(DataInicio);
                lh.DataFim    = DateTime.Parse(DataFim);
                lh.Horas      = Hora;

                await _context.Tb_LancamentosHoras.AddAsync(lh);

                await _context.SaveChangesAsync();

                return(StatusCode(200));
            }
            catch (Exception ex)
            {
                var errorId = Guid.NewGuid();
                _logger.LogError(ex, "ErrorId: {0}", errorId.ToString());
                return(StatusCode(500, new { ErrorId = errorId.ToString(), Mensagem = ex.Message }));
            }
        }
Exemplo n.º 10
0
        public async Task <ActionResult <AppUser> > DeleteAppUser(string id)
        {
            var appUser = await _context.AppUsers.FindAsync(id);

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

            _context.AppUsers.Remove(appUser);
            await _context.SaveChangesAsync();

            return(appUser);
        }
Exemplo n.º 11
0
        public async Task <T> InsertAsync(T item)
        {
            try
            {
                if (item.Id == Guid.Empty)
                {
                    item.Id = Guid.NewGuid();
                    _dataset.Add(item);
                    await _context.SaveChangesAsync();
                }
            }
            catch (Exception)
            {
                item.Id = Guid.Empty;
                return(null);
            }

            return(item);
        }