public async Task <Permission> CheckUseAsync(int perId)
        {
            var param  = DataHelper.GenParams("Id", perId);
            var result = await _adapter.QuerySingle <Permission>(param, "usp_Permission_CheckUse");

            return(result);
        }
Ejemplo n.º 2
0
        //public async Task<IdentityResult> DeleteAsync(ApplicationUser user)
        //{

        //    return IdentityResult.Failed(new IdentityError { Description = $"Could not delete item xxx." });
        //}

        //public async Task<bool> DeleteAsync(int id)
        //{
        //    var user = new UserDelete();
        //    user.Id = id;
        //    int result = await _adapter.ExecuteSingle<UserDelete>(user, "usp_User_Delete");


        //    return true;

        //    //return IdentityResult.Failed(new IdentityError { Description = $"Could not delete this userId {user.Id}." });
        //}
        public async Task <UserCreate> FindById(long userId)
        {
            var dict = new Dictionary <string, object> {
                { "Id", userId }
            };
            var result = await _adapter.QuerySingle <UserCreate>(dict, "usp_User_ReadById");

            return(result);
        }
Ejemplo n.º 3
0
        public async Task <DataService <T> > ReadByIdAsync <T>(dynamic id)
        {
            var type = typeof(T);

            try
            {
                T ret = await _adapter.QuerySingle <T>(DataHelper.GenParams("Id", id), DataHelper.StoreProcedure(type, DataHelper.ApiCRUD.ReadById), DataHelper.GetInstance(type));

                return(ret.FlushData());
            }
            catch (Exception ex)
            {
                return(ex.FatalException <T>());
            }
        }
Ejemplo n.º 4
0
        //public async Task<IdentityResult> CreateAsync(ApplicationRole role)
        //{
        //    var result = await _adapter.ExecuteSingle<ApplicationRole, int>(role, "usp_Role_Create");

        //    if (result > 0)
        //        return IdentityResult.Success;
        //    else if(result == 0)
        //        return IdentityResult.Failed(new IdentityError { Description = $"Duplicate role name {role.Name}." });
        //    return IdentityResult.Failed(new IdentityError { Description = $"Could not insert this role {role.Name}." });
        //}

        //public async Task<IdentityResult> UpdateAsync(ApplicationRole role)
        //{
        //    var result = await _adapter.ExecuteSingle<ApplicationRole, int>(role, "usp_Role_Update");

        //    if (result > 0)
        //        return IdentityResult.Success;
        //    else if (result == 0)
        //        return IdentityResult.Failed(new IdentityError { Description = $"Duplicate role name {role.Name}." });
        //    return IdentityResult.Failed(new IdentityError { Description = $"Could not update this role {role.Name}." });
        //}

        //public async Task<IdentityResult> DeleteAsync(ApplicationRole role)
        //{
        //    return IdentityResult.Failed(new IdentityError { Description = $"Could not delete item xxx." });
        //}
        //public async Task<ApplicationRole> FindByIdAsync(int roleId)
        //{
        //    var param = new Dictionary<string, object> { { "Id", roleId } };
        //    var result = await _adapter.QuerySingle<ApplicationRole>(param, "usp_Role_ReadById");

        //    return result;
        //}

        //public async Task<IEnumerable<ApplicationRole>> GetAllAsync(Dictionary<string, dynamic> obj)
        //{
        //    var result = await _adapter.Query<ApplicationRole>(obj, "usp_Role_Read");

        //    return result;
        //}



        #region Ext
        /// <summary>
        /// Get Permission by UserId
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public async Task <string> ReadByUser(long userId)
        {
            return(await _adapter.QuerySingle <string>(DataHelper.GenParams("UserId", userId), "usp_Role_ReadByUser"));
        }
Ejemplo n.º 5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="id">Module Id</param>
 /// <returns></returns>
 public async Task <Module> ReadByIdAsync(int id)
 {
     return(await _adapter.QuerySingle <Module>(DataHelper.GenParams("Id", id), "usp_Module_ReadById"));
 }