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); } }
public async Task <T> Create(T body) { _db.Add <T>(body); await _db.SaveChangesAsync(); return(body); }
/// <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); }
public async Task SaveAsync(Order order) { if (context.Orders.Find(order.Id) == null) { context.Orders.Add(order); } await context.SaveChangesAsync(); }
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); } }