Exemple #1
0
        /// <summary>
        /// 删除用户角色
        /// </summary>
        /// <param name="guid"></param>
        /// <returns></returns>
        public async Task <APIResult> DeleteUserRole(string guid)
        {
            var result   = new APIResult();
            var userRole = await db.UserRole.Where(a => a.GUID == guid).FirstAsync();

            if (userRole == null)
            {
                result.Fail("无此记录");
                return(result);
            }
            db.UserRole.Remove(userRole);
            db.SaveChanges();
            result.Success();

            return(result);
        }
Exemple #2
0
        public async Task <APIResult> Delete(string guid)
        {
            var result = new APIResult();
            var menu   = await db.MenuInfo.Where(a => a.GUID == guid).FirstAsync();

            if (menu == null)
            {
                result.Fail("无此记录");
                return(result);
            }
            db.MenuInfo.Remove(menu);
            db.SaveChanges();
            result.Success();

            return(result);
        }
Exemple #3
0
        public async Task <APIResult> Edit(RoleInfo role)
        {
            var result = new APIResult();

            try
            {
                db.RoleInfo.Update(role);
                await db.SaveChangesAsync();

                result.Success();
            }
            catch (Exception ex)
            {
                result.Fail(ex.Message);
            }
            return(result);
        }
Exemple #4
0
        public async Task <APIResult> Edit(UserInfo user)
        {
            var result = new APIResult();

            try
            {
                user.PassWord = MD5Encrypt.Encrypt(user.PassWord);

                db.UserInfo.Update(user);
                await db.SaveChangesAsync();

                result.Success();
            }
            catch (Exception ex)
            {
                result.Fail(ex.Message);
            }
            return(result);
        }