/// <summary> /// By default queries the table matching the class name asynchronously. /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> public async Task <IEnumerable <T> > GetListAsync <T>() { SetSimpleCRUD(); using (var conn = new SqlConnection(_connectionString)) { conn.Open(); IEnumerable <T> ret = await _simpleCRUD.GetListAsync <T>(conn); conn.Close(); return(ret); } }
public async Task <JArray> GetAllInventories() { var ItemList = new JArray(); var items = await SimpleCRUD.GetListAsync <InventoryModel>(dbConnection, new { IsActive = true }); return(ItemList = items.Count() > 0 ? JArray.FromObject(items.OrderBy(a => a.Name)) : new JArray()); }
public async Task <bool> IsInventoryItemExist(int InvntId) { bool isExist = false; if (InvntId != 0) { var company = await SimpleCRUD.GetListAsync <InventoryModel>(dbConnection, new { ProductId = InvntId }); if (company.Count() > 0) { isExist = true; } } return(isExist); }
public async Task <int> DeleteInventory(int InvntId) { using (var transaction = _context.Database.BeginTransaction()) { var itemRecord = await SimpleCRUD.GetListAsync <InventoryModel>(dbConnection, new { Id = InvntId }); _context.Remove(itemRecord); var result = await _context.SaveChangesAsync(); if (result > 0) { await transaction.CommitAsync(); } else { await transaction.RollbackAsync(); } return(InvntId); } }
public async Task <object> GetInventoryById(int InvntId) { var itemList = await SimpleCRUD.GetListAsync <InventoryModel>(dbConnection, new { ProductId = InvntId }); return(itemList.Count() > 0 ? JArray.FromObject(itemList.OrderByDescending(a => a.CreatedDate)) : new JArray());; }
public virtual Task <IEnumerable <TModel> > GetListAsync(object whereConditions, IDbTransaction transaction = null, int?commandTimeout = null) { return(SimpleCRUD.GetListAsync <TModel>(_connection, whereConditions, transaction, commandTimeout)); }
public virtual Task <IEnumerable <TModel> > GetListAsync(string conditions, object parameters = null, IDbTransaction transaction = null, int?commandTimeout = null) { return(SimpleCRUD.GetListAsync <TModel>(_connection, conditions, parameters, transaction, commandTimeout)); }