/// <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);
            }
        }
예제 #2
0
        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());
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        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));
 }