public async Task <IActionResult> SetPermission(UserAppsRequest userApps) { try { await this.appService.SetPermission(userApps, this.authHelper.UserId); return(this.Ok()); } catch (Exception ex) { return(this.BadRequest(ex.Message)); } }
/// <summary> /// Sets apps that the user can accessed /// </summary> /// <param name="userApps">User App Request</param> /// <param name="handler">Who doing this action</param> /// <returns>A void task</returns> public async Task SetPermission(UserAppsRequest userApps, int handler) { var account = await this.accountRepository.GetByIdAsync(userApps.Id_NguoiDung); if (account.Quan_Tri == 1) { throw new Exception("Không thể cập nhật đối với tài khoản này"); } var strIds = userApps.Id_ChuongTrinhs == null ? "" : string.Join(",", userApps.Id_ChuongTrinhs); await this.appRepository.SetPermission( userApps.Id_NguoiDung, strIds, handler); }