using HiTeachCC.Service.Core.Interface;
using Microsoft.WindowsAzure.Storage.Table;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
using TEAMModelOS.SDK.Module.AzureTable.Implements;

namespace HiTeachCC.Service.Core.Implement
{
    public class BaseService : AzureTableDBRepository, IBaseService
    {
        public async Task<List<T>> FindListByDictHasAll<T>(Dictionary<string, object> dict) where T : TableEntity, new()
        {
            if (dict.Count <= 0)
            {
                return await FindAll<T>();
            }
            else
            {
                return await FindListByDict<T>(dict);
            }
        }
        public async Task<int> DeleteAll<T>(Dictionary<string, object> dict) where T : TableEntity, new()
        {
            List<T> list = await FindListByDict<T>(dict);
            if (list.IsNotEmpty())
            {
                list = await DeleteAll<T>(list);
                return list.Count;
            }
            else
            {
                return 0;
            }
        }
    }
}
