Exemple #1
0
        public async Task <bool> Save(Documento entity)
        {
            if (entity == null)
            {
                return(false);
            }
            entity.EstadoDocumentoId = (int)EstadoDocumento.Pendiente;
            entity.FechaCreacion     = entity.FechaModificacion = DateTime.Now;
            _context.Documentos.Add(entity);
            try
            {
                var result = await _context.SaveChangesAsync();

                if (result > 0)
                {
                    var provedor = await _provedorService.GetSingle(entity.ProveedorId);

                    if (provedor != null)
                    {
                        provedor.Balance += entity.Monto;
                        return(await _provedorService.Update(provedor));
                    }
                }
                return(result > 0);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Exemple #2
0
        public async Task <T> Create(T body)
        {
            _db.Add <T>(body);
            await _db.SaveChangesAsync();

            return(body);
        }
Exemple #3
0
        /// <summary>
        /// create new record in entity
        /// </summary>
        /// <param name="entity"></param>
        /// <returns>
        /// return id.
        /// </returns>
        public async Task <int> Create(T entity)
        {
            await _dbContext.Set <T>().AddAsync(entity);

            int id = await _dbContext.SaveChangesAsync();

            return(id);
        }
Exemple #4
0
 public async Task SaveAsync(Order order)
 {
     if (context.Orders.Find(order.Id) == null)
     {
         context.Orders.Add(order);
     }
     await context.SaveChangesAsync();
 }
Exemple #5
0
        public async Task <bool> Save(ConceptoPago entity)
        {
            if (entity == null)
            {
                return(false);
            }
            entity.FechaCreacion = entity.FechaModificacion = DateTime.Now;
            entity.Activo        = true;
            _context.ConceptoPago.Add(entity);
            try
            {
                var result = await _context.SaveChangesAsync();

                return(result > 0);
            }
            catch (Exception e)
            {
                return(false);
            }
        }