From b0135fa2bc94e550876e9f13766110bbbe6ef1b5 Mon Sep 17 00:00:00 2001 From: hamed shirbandi Date: Tue, 9 Nov 2021 18:17:37 +0330 Subject: [PATCH] add Members controller to admin panel and some dto and viewModel changes --- .../Permissions/PermissionOutputDto.cs | 6 +- .../Administration/Roles/RoleOutputDto.cs | 1 + .../Dtos/Team/Members/MemberReportDto.cs | 13 ++ .../Organizations/OrganizationReportDto.cs | 6 +- .../Dtos/Team/Projects/ProjectReportDto.cs | 3 +- .../Dtos/Workspace/Boards/BoardReportDto.cs | 3 + .../Dtos/Workspace/Cards/CardReportDto.cs | 8 +- ...lViewModel.cs => BoardDetailsViewModel.cs} | 0 ...ilViewModel.cs => CardDetailsViewModel.cs} | 0 .../ViewModels/MemberDetailsViewModel.cs | 20 +++ ...ewModel.cs => OperatorDetailsViewModel.cs} | 4 +- ...del.cs => OrganizationDetailsViewModel.cs} | 0 ...Model.cs => PermissionDetailsViewModel.cs} | 4 +- ...iewModel.cs => ProjectDetailsViewModel.cs} | 0 ...ilViewModel.cs => RoleDetailsViewModel.cs} | 4 +- .../Operators/Services/IOperatorService.cs | 2 +- .../Operators/Services/OperatorService.cs | 6 +- .../Services/IPermissionService.cs | 2 +- .../Permissions/Services/PermissionService.cs | 6 +- .../Roles/Services/IRoleService.cs | 2 +- .../Roles/Services/RoleService.cs | 6 +- .../Team/Members/Services/IMemberService.cs | 4 +- .../Team/Members/Services/MemberService.cs | 37 ++++++ .../Repositories/InvitationRepository.cs | 52 ++++++++ .../Repositories/OrganizationRepository.cs | 13 ++ .../Controllers/PermissionsController.cs | 8 +- .../Views/Operators/Update.cshtml | 2 +- .../Views/Operators/_UpdateRoles.cshtml | 2 +- .../Views/Permissions/Update.cshtml | 2 +- .../Administration/Views/Roles/Update.cshtml | 2 +- .../Views/Roles/_UpdatePermissions.cshtml | 2 +- .../Team/Controllers/MembersController.cs | 121 ++++++++++++++++++ .../Areas/Team/Views/Members/Details.cshtml | 68 ++++++++++ .../Areas/Team/Views/Members/Index.cshtml | 27 ++++ .../Areas/Team/Views/Members/_ItemList.cshtml | 59 +++++++++ .../Team/Views/Members/_PagedList.cshtml | 33 +++++ .../Shared/Components/UserMenu/Default.cshtml | 28 ++++ .../Views/Shared/_AdminLayout.cshtml | 2 +- Src/Presentation/Web.Admin/Web.Admin.csproj | 4 + .../content/img/default-user-avatar.jpg | Bin 0 -> 1980 bytes .../Web.Common/Components/UserMenu.cs | 44 +++++++ .../Controllers/BaseMvcController.cs | 20 ++- .../Areas/Admin/Views/Dashboard/Index.cshtml | 4 +- 43 files changed, 586 insertions(+), 44 deletions(-) create mode 100644 Src/Libraries/1-Application/Application.Core/Dtos/Team/Members/MemberReportDto.cs rename Src/Libraries/1-Application/Application.Core/ViewModels/{BoardDetailViewModel.cs => BoardDetailsViewModel.cs} (100%) rename Src/Libraries/1-Application/Application.Core/ViewModels/{CardDetailViewModel.cs => CardDetailsViewModel.cs} (100%) create mode 100644 Src/Libraries/1-Application/Application.Core/ViewModels/MemberDetailsViewModel.cs rename Src/Libraries/1-Application/Application.Core/ViewModels/{OperatorDetailViewModel.cs => OperatorDetailsViewModel.cs} (84%) rename Src/Libraries/1-Application/Application.Core/ViewModels/{OrganizationDetailViewModel.cs => OrganizationDetailsViewModel.cs} (100%) rename Src/Libraries/1-Application/Application.Core/ViewModels/{PermissionDetailViewModel.cs => PermissionDetailsViewModel.cs} (84%) rename Src/Libraries/1-Application/Application.Core/ViewModels/{ProjectDetailViewModel.cs => ProjectDetailsViewModel.cs} (100%) rename Src/Libraries/1-Application/Application.Core/ViewModels/{RoleDetailViewModel.cs => RoleDetailsViewModel.cs} (89%) create mode 100644 Src/Libraries/2-Infrastructure/Infrastructure.Data/Repositories/InvitationRepository.cs create mode 100644 Src/Presentation/Web.Admin/Areas/Team/Controllers/MembersController.cs create mode 100644 Src/Presentation/Web.Admin/Areas/Team/Views/Members/Details.cshtml create mode 100644 Src/Presentation/Web.Admin/Areas/Team/Views/Members/Index.cshtml create mode 100644 Src/Presentation/Web.Admin/Areas/Team/Views/Members/_ItemList.cshtml create mode 100644 Src/Presentation/Web.Admin/Areas/Team/Views/Members/_PagedList.cshtml create mode 100644 Src/Presentation/Web.Admin/Views/Shared/Components/UserMenu/Default.cshtml create mode 100644 Src/Presentation/Web.Admin/wwwroot/content/img/default-user-avatar.jpg create mode 100644 Src/Presentation/Web.Common/Components/UserMenu.cs diff --git a/Src/Libraries/1-Application/Application.Core/Dtos/Administration/Permissions/PermissionOutputDto.cs b/Src/Libraries/1-Application/Application.Core/Dtos/Administration/Permissions/PermissionOutputDto.cs index 63a970d4a..e203ebfd4 100644 --- a/Src/Libraries/1-Application/Application.Core/Dtos/Administration/Permissions/PermissionOutputDto.cs +++ b/Src/Libraries/1-Application/Application.Core/Dtos/Administration/Permissions/PermissionOutputDto.cs @@ -1,7 +1,11 @@ -namespace TaskoMask.Application.Core.Dtos.Administration.Permissions +using System.ComponentModel.DataAnnotations; +using TaskoMask.Application.Core.Resources; + +namespace TaskoMask.Application.Core.Dtos.Administration.Permissions { public class PermissionOutputDto : PermissionBasicInfoDto { + [Display(Name = nameof(ApplicationMetadata.RolesCount), ResourceType = typeof(ApplicationMetadata))] public long RolesCount { get; set; } } } diff --git a/Src/Libraries/1-Application/Application.Core/Dtos/Administration/Roles/RoleOutputDto.cs b/Src/Libraries/1-Application/Application.Core/Dtos/Administration/Roles/RoleOutputDto.cs index ad0a096b7..203e69f32 100644 --- a/Src/Libraries/1-Application/Application.Core/Dtos/Administration/Roles/RoleOutputDto.cs +++ b/Src/Libraries/1-Application/Application.Core/Dtos/Administration/Roles/RoleOutputDto.cs @@ -7,6 +7,7 @@ public class RoleOutputDto : RoleBasicInfoDto { [Display(Name = nameof(ApplicationMetadata.OperatorsCount), ResourceType = typeof(ApplicationMetadata))] public long OperatorsCount { get; set; } + [Display(Name = nameof(ApplicationMetadata.PermissionsCount), ResourceType = typeof(ApplicationMetadata))] public long PermissionsCount { get; set; } diff --git a/Src/Libraries/1-Application/Application.Core/Dtos/Team/Members/MemberReportDto.cs b/Src/Libraries/1-Application/Application.Core/Dtos/Team/Members/MemberReportDto.cs new file mode 100644 index 000000000..e170425dc --- /dev/null +++ b/Src/Libraries/1-Application/Application.Core/Dtos/Team/Members/MemberReportDto.cs @@ -0,0 +1,13 @@ +using System.ComponentModel.DataAnnotations; +using TaskoMask.Application.Core.Dtos.Team.Organizations; +using TaskoMask.Application.Core.Resources; + +namespace TaskoMask.Application.Core.Dtos.Team.Members +{ + public class MemberReportDto : OrganizationReportDto + { + [Display(Name = nameof(ApplicationMetadata.OrganizationsCount), ResourceType = typeof(ApplicationMetadata))] + public int OrganizationsCount { get; set; } + + } +} diff --git a/Src/Libraries/1-Application/Application.Core/Dtos/Team/Organizations/OrganizationReportDto.cs b/Src/Libraries/1-Application/Application.Core/Dtos/Team/Organizations/OrganizationReportDto.cs index 49d6b9b1d..5473ec0fd 100644 --- a/Src/Libraries/1-Application/Application.Core/Dtos/Team/Organizations/OrganizationReportDto.cs +++ b/Src/Libraries/1-Application/Application.Core/Dtos/Team/Organizations/OrganizationReportDto.cs @@ -1,16 +1,14 @@ using System.ComponentModel.DataAnnotations; +using TaskoMask.Application.Core.Dtos.Team.Projects; using TaskoMask.Application.Core.Dtos.Workspace.Tasks; using TaskoMask.Application.Core.Resources; namespace TaskoMask.Application.Core.Dtos.Team.Organizations { - public class OrganizationReportDto : TaskReportDto + public class OrganizationReportDto : ProjectReportDto { [Display(Name = nameof(ApplicationMetadata.ProjectsCount), ResourceType = typeof(ApplicationMetadata))] public int ProjectsCount { get; set; } - - [Display(Name = nameof(ApplicationMetadata.MembersCount), ResourceType = typeof(ApplicationMetadata))] - public int MembersCount { get; set; } } } diff --git a/Src/Libraries/1-Application/Application.Core/Dtos/Team/Projects/ProjectReportDto.cs b/Src/Libraries/1-Application/Application.Core/Dtos/Team/Projects/ProjectReportDto.cs index 62b84ea36..9ed04dcbd 100644 --- a/Src/Libraries/1-Application/Application.Core/Dtos/Team/Projects/ProjectReportDto.cs +++ b/Src/Libraries/1-Application/Application.Core/Dtos/Team/Projects/ProjectReportDto.cs @@ -1,10 +1,11 @@ using System.ComponentModel.DataAnnotations; +using TaskoMask.Application.Core.Dtos.Workspace.Boards; using TaskoMask.Application.Core.Dtos.Workspace.Tasks; using TaskoMask.Application.Core.Resources; namespace TaskoMask.Application.Core.Dtos.Team.Projects { - public class ProjectReportDto : TaskReportDto + public class ProjectReportDto : BoardReportDto { [Display(Name = nameof(ApplicationMetadata.BoardsCount), ResourceType = typeof(ApplicationMetadata))] public int BoardsCount { get; set; } diff --git a/Src/Libraries/1-Application/Application.Core/Dtos/Workspace/Boards/BoardReportDto.cs b/Src/Libraries/1-Application/Application.Core/Dtos/Workspace/Boards/BoardReportDto.cs index ac76eedc1..6c8c39e4a 100644 --- a/Src/Libraries/1-Application/Application.Core/Dtos/Workspace/Boards/BoardReportDto.cs +++ b/Src/Libraries/1-Application/Application.Core/Dtos/Workspace/Boards/BoardReportDto.cs @@ -8,5 +8,8 @@ public class BoardReportDto: TaskReportDto { [Display(Name = nameof(ApplicationMetadata.CardsCount), ResourceType = typeof(ApplicationMetadata))] public int CardsCount { get; set; } + + [Display(Name = nameof(ApplicationMetadata.MembersCount), ResourceType = typeof(ApplicationMetadata))] + public int InvitedMembersCount { get; set; } } } diff --git a/Src/Libraries/1-Application/Application.Core/Dtos/Workspace/Cards/CardReportDto.cs b/Src/Libraries/1-Application/Application.Core/Dtos/Workspace/Cards/CardReportDto.cs index 0ebc985ff..d85b7effc 100644 --- a/Src/Libraries/1-Application/Application.Core/Dtos/Workspace/Cards/CardReportDto.cs +++ b/Src/Libraries/1-Application/Application.Core/Dtos/Workspace/Cards/CardReportDto.cs @@ -1,9 +1,11 @@ -using TaskoMask.Application.Core.Dtos.Workspace.Tasks; +using System.ComponentModel.DataAnnotations; +using TaskoMask.Application.Core.Resources; namespace TaskoMask.Application.Core.Dtos.Workspace.Cards { - public class CardReportDto: TaskReportDto + public class CardReportDto { - + [Display(Name = nameof(ApplicationMetadata.TasksCount), ResourceType = typeof(ApplicationMetadata))] + public int TasksCount { get; set; } } } diff --git a/Src/Libraries/1-Application/Application.Core/ViewModels/BoardDetailViewModel.cs b/Src/Libraries/1-Application/Application.Core/ViewModels/BoardDetailsViewModel.cs similarity index 100% rename from Src/Libraries/1-Application/Application.Core/ViewModels/BoardDetailViewModel.cs rename to Src/Libraries/1-Application/Application.Core/ViewModels/BoardDetailsViewModel.cs diff --git a/Src/Libraries/1-Application/Application.Core/ViewModels/CardDetailViewModel.cs b/Src/Libraries/1-Application/Application.Core/ViewModels/CardDetailsViewModel.cs similarity index 100% rename from Src/Libraries/1-Application/Application.Core/ViewModels/CardDetailViewModel.cs rename to Src/Libraries/1-Application/Application.Core/ViewModels/CardDetailsViewModel.cs diff --git a/Src/Libraries/1-Application/Application.Core/ViewModels/MemberDetailsViewModel.cs b/Src/Libraries/1-Application/Application.Core/ViewModels/MemberDetailsViewModel.cs new file mode 100644 index 000000000..ccc4397a1 --- /dev/null +++ b/Src/Libraries/1-Application/Application.Core/ViewModels/MemberDetailsViewModel.cs @@ -0,0 +1,20 @@ +using System.Collections.Generic; +using TaskoMask.Application.Core.Dtos.Administration.Operators; +using TaskoMask.Application.Core.Dtos.Team.Members; +using TaskoMask.Application.Core.Dtos.Team.Organizations; +using TaskoMask.Application.Core.Helpers; + +namespace TaskoMask.Application.Core.ViewModels +{ + public class MemberDetailsViewModel + { + public MemberDetailsViewModel() + { + + } + + public MemberBasicInfoDto Member { get; set; } + public IEnumerable Organizations { get; set; } + + } +} diff --git a/Src/Libraries/1-Application/Application.Core/ViewModels/OperatorDetailViewModel.cs b/Src/Libraries/1-Application/Application.Core/ViewModels/OperatorDetailsViewModel.cs similarity index 84% rename from Src/Libraries/1-Application/Application.Core/ViewModels/OperatorDetailViewModel.cs rename to Src/Libraries/1-Application/Application.Core/ViewModels/OperatorDetailsViewModel.cs index 58cef82b0..40230b174 100644 --- a/Src/Libraries/1-Application/Application.Core/ViewModels/OperatorDetailViewModel.cs +++ b/Src/Libraries/1-Application/Application.Core/ViewModels/OperatorDetailsViewModel.cs @@ -5,9 +5,9 @@ namespace TaskoMask.Application.Core.ViewModels { - public class OperatorDetailViewModel + public class OperatorDetailsViewModel { - public OperatorDetailViewModel() + public OperatorDetailsViewModel() { Roles = new List(); } diff --git a/Src/Libraries/1-Application/Application.Core/ViewModels/OrganizationDetailViewModel.cs b/Src/Libraries/1-Application/Application.Core/ViewModels/OrganizationDetailsViewModel.cs similarity index 100% rename from Src/Libraries/1-Application/Application.Core/ViewModels/OrganizationDetailViewModel.cs rename to Src/Libraries/1-Application/Application.Core/ViewModels/OrganizationDetailsViewModel.cs diff --git a/Src/Libraries/1-Application/Application.Core/ViewModels/PermissionDetailViewModel.cs b/Src/Libraries/1-Application/Application.Core/ViewModels/PermissionDetailsViewModel.cs similarity index 84% rename from Src/Libraries/1-Application/Application.Core/ViewModels/PermissionDetailViewModel.cs rename to Src/Libraries/1-Application/Application.Core/ViewModels/PermissionDetailsViewModel.cs index 6b1d4040c..99d7fc1ad 100644 --- a/Src/Libraries/1-Application/Application.Core/ViewModels/PermissionDetailViewModel.cs +++ b/Src/Libraries/1-Application/Application.Core/ViewModels/PermissionDetailsViewModel.cs @@ -4,9 +4,9 @@ namespace TaskoMask.Application.Core.ViewModels { - public class PermissionDetailViewModel + public class PermissionDetailsViewModel { - public PermissionDetailViewModel() + public PermissionDetailsViewModel() { Permission = new PermissionUpsertDto(); Roles = new List(); diff --git a/Src/Libraries/1-Application/Application.Core/ViewModels/ProjectDetailViewModel.cs b/Src/Libraries/1-Application/Application.Core/ViewModels/ProjectDetailsViewModel.cs similarity index 100% rename from Src/Libraries/1-Application/Application.Core/ViewModels/ProjectDetailViewModel.cs rename to Src/Libraries/1-Application/Application.Core/ViewModels/ProjectDetailsViewModel.cs diff --git a/Src/Libraries/1-Application/Application.Core/ViewModels/RoleDetailViewModel.cs b/Src/Libraries/1-Application/Application.Core/ViewModels/RoleDetailsViewModel.cs similarity index 89% rename from Src/Libraries/1-Application/Application.Core/ViewModels/RoleDetailViewModel.cs rename to Src/Libraries/1-Application/Application.Core/ViewModels/RoleDetailsViewModel.cs index f2c8bc937..46acc6828 100644 --- a/Src/Libraries/1-Application/Application.Core/ViewModels/RoleDetailViewModel.cs +++ b/Src/Libraries/1-Application/Application.Core/ViewModels/RoleDetailsViewModel.cs @@ -5,9 +5,9 @@ namespace TaskoMask.Application.Core.ViewModels { - public class RoleDetailViewModel + public class RoleDetailsViewModel { - public RoleDetailViewModel() + public RoleDetailsViewModel() { Operators = new List(); Permissions = new Dictionary>(); diff --git a/Src/Libraries/1-Application/Application/Administration/Operators/Services/IOperatorService.cs b/Src/Libraries/1-Application/Application/Administration/Operators/Services/IOperatorService.cs index d18707cf4..cd92a88f4 100644 --- a/Src/Libraries/1-Application/Application/Administration/Operators/Services/IOperatorService.cs +++ b/Src/Libraries/1-Application/Application/Administration/Operators/Services/IOperatorService.cs @@ -15,7 +15,7 @@ public interface IOperatorService : IUserService Task> UpdateAsync(OperatorUpsertDto input); Task> GetByIdAsync(string id); Task>> GetListAsync(); - Task> GetDetailsAsync(string id); + Task> GetDetailsAsync(string id); Task> UpdateRolesAsync(string id, string[] rolesId); } } diff --git a/Src/Libraries/1-Application/Application/Administration/Operators/Services/OperatorService.cs b/Src/Libraries/1-Application/Application/Administration/Operators/Services/OperatorService.cs index 70025b6ed..d17441804 100644 --- a/Src/Libraries/1-Application/Application/Administration/Operators/Services/OperatorService.cs +++ b/Src/Libraries/1-Application/Application/Administration/Operators/Services/OperatorService.cs @@ -139,15 +139,15 @@ public async Task>> GetListAsync() /// /// /// - public async Task> GetDetailsAsync(string id) + public async Task> GetDetailsAsync(string id) { var @operator = await _operatorRepository.GetByIdAsync(id); if (@operator == null) - return Result.Failure(message: string.Format(ApplicationMessages.Data_Not_exist, DomainMetadata.Operator)); + return Result.Failure(message: string.Format(ApplicationMessages.Data_Not_exist, DomainMetadata.Operator)); var roles = await _roleRepository.GetListAsync(); - var model = new OperatorDetailViewModel + var model = new OperatorDetailsViewModel { Operator = _mapper.Map(@operator), Roles = roles.Select(role => new SelectListItem diff --git a/Src/Libraries/1-Application/Application/Administration/Permissions/Services/IPermissionService.cs b/Src/Libraries/1-Application/Application/Administration/Permissions/Services/IPermissionService.cs index efd2dba88..dde3eee8d 100644 --- a/Src/Libraries/1-Application/Application/Administration/Permissions/Services/IPermissionService.cs +++ b/Src/Libraries/1-Application/Application/Administration/Permissions/Services/IPermissionService.cs @@ -14,7 +14,7 @@ public interface IPermissionService : IBaseService Task> UpdateAsync(PermissionUpsertDto input); Task> GetByIdAsync(string id); - Task> GetDetailsAsync(string id); + Task> GetDetailsAsync(string id); Task>> GetListAsync(string id); Task>> GetListByIdsAsync(string[] ids); Task> GetSystemNameListByOperatorAsync(string userName); diff --git a/Src/Libraries/1-Application/Application/Administration/Permissions/Services/PermissionService.cs b/Src/Libraries/1-Application/Application/Administration/Permissions/Services/PermissionService.cs index ba6850a71..dc92d3838 100644 --- a/Src/Libraries/1-Application/Application/Administration/Permissions/Services/PermissionService.cs +++ b/Src/Libraries/1-Application/Application/Administration/Permissions/Services/PermissionService.cs @@ -111,17 +111,17 @@ public async Task> GetByIdAsync(string id) /// /// /// - public async Task> GetDetailsAsync(string id) + public async Task> GetDetailsAsync(string id) { var permission = await _permissionRepository.GetByIdAsync(id); if (permission == null) - return Result.Failure(message: string.Format(ApplicationMessages.Data_Not_exist, DomainMetadata.Permission)); + return Result.Failure(message: string.Format(ApplicationMessages.Data_Not_exist, DomainMetadata.Permission)); var roles = await _roleRepository.GetListByPermissionIdAsync(id); - var model = new PermissionDetailViewModel + var model = new PermissionDetailsViewModel { Permission = _mapper.Map(permission), Roles = _mapper.Map>(roles) diff --git a/Src/Libraries/1-Application/Application/Administration/Roles/Services/IRoleService.cs b/Src/Libraries/1-Application/Application/Administration/Roles/Services/IRoleService.cs index 2f38cfdb0..d3cc50edd 100644 --- a/Src/Libraries/1-Application/Application/Administration/Roles/Services/IRoleService.cs +++ b/Src/Libraries/1-Application/Application/Administration/Roles/Services/IRoleService.cs @@ -13,7 +13,7 @@ public interface IRoleService : IBaseService Task> CreateAsync(RoleUpsertDto input); Task> UpdateAsync(RoleUpsertDto input); Task> UpdatePermissionsAsync(string id, string[]permissionsId); - Task> GetDetailsAsync(string id); + Task> GetDetailsAsync(string id); Task> GetByIdAsync(string id); Task>> GetListAsync(); } diff --git a/Src/Libraries/1-Application/Application/Administration/Roles/Services/RoleService.cs b/Src/Libraries/1-Application/Application/Administration/Roles/Services/RoleService.cs index b1344ce54..0b2f9d870 100644 --- a/Src/Libraries/1-Application/Application/Administration/Roles/Services/RoleService.cs +++ b/Src/Libraries/1-Application/Application/Administration/Roles/Services/RoleService.cs @@ -144,18 +144,18 @@ public async Task>> GetListAsync() /// /// /// - public async Task> GetDetailsAsync(string id) + public async Task> GetDetailsAsync(string id) { var role = await _roleRepository.GetByIdAsync(id); if (role == null) - return Result.Failure(message: string.Format(ApplicationMessages.Data_Not_exist, DomainMetadata.Role)); + return Result.Failure(message: string.Format(ApplicationMessages.Data_Not_exist, DomainMetadata.Role)); var operators = await _operatorRepository.GetListByRoleIdAsync(id); var permissions = await _permissionRepository.GetListAsync(); - var model = new RoleDetailViewModel + var model = new RoleDetailsViewModel { Role = _mapper.Map(role), Operators = _mapper.Map>(operators), diff --git a/Src/Libraries/1-Application/Application/Team/Members/Services/IMemberService.cs b/Src/Libraries/1-Application/Application/Team/Members/Services/IMemberService.cs index a0cf94949..4389b3308 100644 --- a/Src/Libraries/1-Application/Application/Team/Members/Services/IMemberService.cs +++ b/Src/Libraries/1-Application/Application/Team/Members/Services/IMemberService.cs @@ -4,6 +4,7 @@ using TaskoMask.Application.Core.Commands; using TaskoMask.Application.Common.Users.Services; using TaskoMask.Application.Core.Dtos.Team.Members; +using TaskoMask.Application.Core.ViewModels; namespace TaskoMask.Application.Team.Members.Services { @@ -12,6 +13,7 @@ public interface IMemberService : IUserService Task> CreateAsync(MemberRegisterDto input); Task> UpdateAsync(UserUpsertDto input); Task> GetByIdAsync(string id); - Task> ValidateUserPasswordAsync(string userName,string password); + Task>> SearchAsync(int page, int recordsPerPage, string term); + Task> GetDetailsAsync(string id); } } diff --git a/Src/Libraries/1-Application/Application/Team/Members/Services/MemberService.cs b/Src/Libraries/1-Application/Application/Team/Members/Services/MemberService.cs index cc26c32f5..7c2648ab4 100644 --- a/Src/Libraries/1-Application/Application/Team/Members/Services/MemberService.cs +++ b/Src/Libraries/1-Application/Application/Team/Members/Services/MemberService.cs @@ -12,6 +12,8 @@ using TaskoMask.Domain.Team.Entities; using TaskoMask.Domain.Core.Services; using TaskoMask.Domain.Team.Data; +using TaskoMask.Application.Core.ViewModels; +using TaskoMask.Application.Team.Organizations.Queries.Models; namespace TaskoMask.Application.Team.Members.Services { @@ -67,6 +69,41 @@ public async Task> GetByIdAsync(string id) + /// + /// + /// + public async Task>> SearchAsync(int page, int recordsPerPage, string term) + { + return await SendQueryAsync(new SearchMembersQuery(page, recordsPerPage, term)); + + } + + + + /// + /// + /// + public async Task> GetDetailsAsync(string id) + { + var memberQueryResult = await SendQueryAsync(new GetMemberByIdQuery(id)); + if (!memberQueryResult.IsSuccess) + return Result.Failure(memberQueryResult.Errors); + + + var organizationQueryResult = await SendQueryAsync(new GetOrganizationsByOwnerMemberIdQuery(memberQueryResult.Value.Id)); + if (!organizationQueryResult.IsSuccess) + return Result.Failure(organizationQueryResult.Errors); + + + var projectDetail = new MemberDetailsViewModel + { + Member = memberQueryResult.Value, + Organizations = organizationQueryResult.Value, + }; + + return Result.Success(projectDetail); + } + #endregion } diff --git a/Src/Libraries/2-Infrastructure/Infrastructure.Data/Repositories/InvitationRepository.cs b/Src/Libraries/2-Infrastructure/Infrastructure.Data/Repositories/InvitationRepository.cs new file mode 100644 index 000000000..b71774aa3 --- /dev/null +++ b/Src/Libraries/2-Infrastructure/Infrastructure.Data/Repositories/InvitationRepository.cs @@ -0,0 +1,52 @@ +using MongoDB.Driver; +using MongoDB.Driver.Linq; +using System.Collections.Generic; +using System.Threading.Tasks; +using TaskoMask.Domain.Team.Data; +using TaskoMask.Domain.Team.Entities; +using TaskoMask.Infrastructure.Data.DbContext; + +namespace TaskoMask.Infrastructure.Data.Repositories +{ + public class InvitationRepository : BaseRepository, IInvitationRepository + { + #region Fields + + private readonly IMongoCollection _invitations; + + #endregion + + #region Ctors + + public InvitationRepository(IMongoDbContext dbContext) : base(dbContext) + { + _invitations = dbContext.GetCollection(); + } + + + + + + #endregion + + #region Public Methods + + public async Task OrganizationsCountByInvitedMemberIdAsync(string invitedMemberId) + { + return await _invitations.AsQueryable() + .Where(i => i.InvitedMemberId == invitedMemberId) + .Select(i => i.OrganizationId).Distinct().CountAsync(); + } + + + + #endregion + + #region Private Methods + + + + #endregion + + } +} diff --git a/Src/Libraries/2-Infrastructure/Infrastructure.Data/Repositories/OrganizationRepository.cs b/Src/Libraries/2-Infrastructure/Infrastructure.Data/Repositories/OrganizationRepository.cs index 35839229a..68347e37b 100644 --- a/Src/Libraries/2-Infrastructure/Infrastructure.Data/Repositories/OrganizationRepository.cs +++ b/Src/Libraries/2-Infrastructure/Infrastructure.Data/Repositories/OrganizationRepository.cs @@ -23,6 +23,8 @@ public OrganizationRepository(IMongoDbContext dbContext) : base(dbContext) _organizations = dbContext.GetCollection(); } + + #endregion #region Public Methods @@ -48,6 +50,17 @@ public async Task> GetListByOwnerMemberIdAsync(string return await _organizations.AsQueryable().Where(o => o.OwnerMemberId == ownerMemberId).ToListAsync(); } + + + /// + /// + /// + public async Task CountByOwnerMemberIdAsync(string ownerMemberId) + { + return await _organizations.CountDocumentsAsync(o => o.OwnerMemberId== ownerMemberId); + } + + #endregion #region Private Methods diff --git a/Src/Presentation/Web.Admin/Areas/Administration/Controllers/PermissionsController.cs b/Src/Presentation/Web.Admin/Areas/Administration/Controllers/PermissionsController.cs index 1a58166eb..9eeccbc77 100644 --- a/Src/Presentation/Web.Admin/Areas/Administration/Controllers/PermissionsController.cs +++ b/Src/Presentation/Web.Admin/Areas/Administration/Controllers/PermissionsController.cs @@ -20,9 +20,6 @@ public class PermissionsController : BaseMvcController #region Fields private readonly IPermissionService _permissionService; - protected int recordsPerPage; - protected int pageSize; - protected int totalItemCount; #endregion @@ -31,9 +28,7 @@ public class PermissionsController : BaseMvcController public PermissionsController(IPermissionService permissionService, IMapper mapper) : base(mapper) { _permissionService = permissionService; - pageSize = 0; - recordsPerPage = 15; - totalItemCount = 0; + } #endregion @@ -163,7 +158,6 @@ public async Task Update(PermissionUpsertDto input) #endregion - #region Private Methods diff --git a/Src/Presentation/Web.Admin/Areas/Administration/Views/Operators/Update.cshtml b/Src/Presentation/Web.Admin/Areas/Administration/Views/Operators/Update.cshtml index 76f2bed12..973771020 100644 --- a/Src/Presentation/Web.Admin/Areas/Administration/Views/Operators/Update.cshtml +++ b/Src/Presentation/Web.Admin/Areas/Administration/Views/Operators/Update.cshtml @@ -1,4 +1,4 @@ -@model TaskoMask.Application.Core.ViewModels.OperatorDetailViewModel +@model TaskoMask.Application.Core.ViewModels.OperatorDetailsViewModel @using TaskoMask.Application.Core.Dtos.Common.Users @{ diff --git a/Src/Presentation/Web.Admin/Areas/Administration/Views/Operators/_UpdateRoles.cshtml b/Src/Presentation/Web.Admin/Areas/Administration/Views/Operators/_UpdateRoles.cshtml index 4b1ea030e..623534fd0 100644 --- a/Src/Presentation/Web.Admin/Areas/Administration/Views/Operators/_UpdateRoles.cshtml +++ b/Src/Presentation/Web.Admin/Areas/Administration/Views/Operators/_UpdateRoles.cshtml @@ -1,4 +1,4 @@ -@model TaskoMask.Application.Core.ViewModels.OperatorDetailViewModel +@model TaskoMask.Application.Core.ViewModels.OperatorDetailsViewModel
diff --git a/Src/Presentation/Web.Admin/Areas/Administration/Views/Permissions/Update.cshtml b/Src/Presentation/Web.Admin/Areas/Administration/Views/Permissions/Update.cshtml index d294df60f..60979d063 100644 --- a/Src/Presentation/Web.Admin/Areas/Administration/Views/Permissions/Update.cshtml +++ b/Src/Presentation/Web.Admin/Areas/Administration/Views/Permissions/Update.cshtml @@ -1,4 +1,4 @@ -@model TaskoMask.Application.Core.ViewModels.PermissionDetailViewModel +@model TaskoMask.Application.Core.ViewModels.PermissionDetailsViewModel @{ ViewBag.Title = "Update Permission"; diff --git a/Src/Presentation/Web.Admin/Areas/Administration/Views/Roles/Update.cshtml b/Src/Presentation/Web.Admin/Areas/Administration/Views/Roles/Update.cshtml index a2c88263b..866075f97 100644 --- a/Src/Presentation/Web.Admin/Areas/Administration/Views/Roles/Update.cshtml +++ b/Src/Presentation/Web.Admin/Areas/Administration/Views/Roles/Update.cshtml @@ -1,4 +1,4 @@ -@model TaskoMask.Application.Core.ViewModels.RoleDetailViewModel +@model TaskoMask.Application.Core.ViewModels.RoleDetailsViewModel @{ ViewBag.Title = "Update Role"; diff --git a/Src/Presentation/Web.Admin/Areas/Administration/Views/Roles/_UpdatePermissions.cshtml b/Src/Presentation/Web.Admin/Areas/Administration/Views/Roles/_UpdatePermissions.cshtml index 88dad6c15..451b29643 100644 --- a/Src/Presentation/Web.Admin/Areas/Administration/Views/Roles/_UpdatePermissions.cshtml +++ b/Src/Presentation/Web.Admin/Areas/Administration/Views/Roles/_UpdatePermissions.cshtml @@ -1,4 +1,4 @@ -@model TaskoMask.Application.Core.ViewModels.RoleDetailViewModel +@model TaskoMask.Application.Core.ViewModels.RoleDetailsViewModel
diff --git a/Src/Presentation/Web.Admin/Areas/Team/Controllers/MembersController.cs b/Src/Presentation/Web.Admin/Areas/Team/Controllers/MembersController.cs new file mode 100644 index 000000000..d1ec7ab60 --- /dev/null +++ b/Src/Presentation/Web.Admin/Areas/Team/Controllers/MembersController.cs @@ -0,0 +1,121 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using AutoMapper; +using TaskoMask.Web.Common.Controllers; +using TaskoMask.Application.Team.Members.Services; +using System.Threading.Tasks; +using TaskoMask.Web.Common.Filters; +using TaskoMask.Web.Common.Helpers; + +namespace Aghoosh.Web.Admin.Areas.Accounting.Controllers +{ + [Authorize] + [Area("Accounting")] + public class MembersController : BaseMvcController + { + #region Fields + + private readonly IMemberService _memberService; + + + #endregion + + #region Ctor + + public MembersController(IMemberService memberService, IMapper mapper) : base(mapper) + { + _memberService = memberService; + } + + #endregion + + #region Public Methods + + + + /// + /// + /// + [HttpGet] + public async Task Index() + { + var memberQueryResult = await _memberService.SearchAsync(page: 1, recordsPerPage: recordsPerPage, term: ""); + + #region ViewBags + + ViewBag.PageSize = memberQueryResult.Value.PageNumber; + ViewBag.CurrentPage = 1; + ViewBag.TotalItemCount = memberQueryResult.Value.TotalCount; + + #endregion + + return View(memberQueryResult); + } + + + + /// + /// + /// + [HttpGet] + [AjaxOnly] + public async Task Search(int page = 1, string term = "") + { + var memberQueryResult = await _memberService.SearchAsync(page: page, recordsPerPage: recordsPerPage, term: term); + + if (!memberQueryResult.IsSuccess) + return RedirectToErrorPage(memberQueryResult); + + #region ViewBags + + ViewBag.PageSize = memberQueryResult.Value.PageNumber; + ViewBag.CurrentPage = page; + ViewBag.TotalItemCount = memberQueryResult.Value.TotalCount; + + #endregion + + return PartialView("_ItemList", memberQueryResult.Value.Items); + } + + + + /// + /// + /// + [HttpGet] + public async Task Details(string id) + { + var memberQueryResult = await _memberService.GetDetailsAsync(id); + + return View(memberQueryResult); + + } + + + + /// + /// + /// + [HttpPost] + [AjaxOnly] + [IgnoreAntiforgeryToken] + public async Task SetIsActive(string id, bool isActive) + { + var cmdResult = await _memberService.SetIsActiveAsync(id, isActive); + return AjaxResult(cmdResult, reloadPage: true); + + } + + + + + #endregion + + #region Private Methods + + + + #endregion + + } +} diff --git a/Src/Presentation/Web.Admin/Areas/Team/Views/Members/Details.cshtml b/Src/Presentation/Web.Admin/Areas/Team/Views/Members/Details.cshtml new file mode 100644 index 000000000..60979d063 --- /dev/null +++ b/Src/Presentation/Web.Admin/Areas/Team/Views/Members/Details.cshtml @@ -0,0 +1,68 @@ +@model TaskoMask.Application.Core.ViewModels.PermissionDetailsViewModel + +@{ + ViewBag.Title = "Update Permission"; +} + +
+
+
+

Basic Info

+
+
+ @await Html.PartialAsync("_SaveForm", Model.Permission) +
+
+
+ +
+
+
+

Roles

+
+
+
+ + + + + + + + + + @foreach (var item in Model.Roles) + { + + + + + + + + } + + +
@Html.LabelFor(model => model.Roles.FirstOrDefault().Name)@Html.LabelFor(model => model.Roles.FirstOrDefault().PermissionsId)
+ @item.Name + + @item.PermissionsId.Length + +
+ + + +
+
+
+ +
+
+
+ + + + +@section scripts{ + +} diff --git a/Src/Presentation/Web.Admin/Areas/Team/Views/Members/Index.cshtml b/Src/Presentation/Web.Admin/Areas/Team/Views/Members/Index.cshtml new file mode 100644 index 000000000..6f55440fa --- /dev/null +++ b/Src/Presentation/Web.Admin/Areas/Team/Views/Members/Index.cshtml @@ -0,0 +1,27 @@ +@model TaskoMask.Application.Core.Helpers.PublicPaginatedListReturnType +@{ + ViewBag.Title = "Permissions List"; +} + +
+
+
+ + New Permission + + @Html.DropDownList("GroupName", null, "All Groups", new { @class = "" }) + + + + +
+
+ @await Html.PartialAsync("_ItemList", Model.Items) +
+
+
+ + +@section scripts{ + +} \ No newline at end of file diff --git a/Src/Presentation/Web.Admin/Areas/Team/Views/Members/_ItemList.cshtml b/Src/Presentation/Web.Admin/Areas/Team/Views/Members/_ItemList.cshtml new file mode 100644 index 000000000..7d01aae6c --- /dev/null +++ b/Src/Presentation/Web.Admin/Areas/Team/Views/Members/_ItemList.cshtml @@ -0,0 +1,59 @@ +@model IEnumerable + +@if (Model.Count() == 0) +{ +
+
+

No item to show!

+
+
+} +else +{ +
+
+ + + + + + + + + + + + @foreach (var item in Model) + { + + + + + + + + + } + + +
@Html.LabelFor(model => model.FirstOrDefault().DisplayName)@Html.LabelFor(model => model.FirstOrDefault().SystemName)@Html.LabelFor(model => model.FirstOrDefault().GroupName)@Html.LabelFor(model => model.FirstOrDefault().RolesCount)
+ @item.DisplayName + + @item.SystemName + + @item.GroupName + + @item.RolesCount + +
+ + + +
+
+
+
+ @await Html.PartialAsync("_PagedList") +} + + diff --git a/Src/Presentation/Web.Admin/Areas/Team/Views/Members/_PagedList.cshtml b/Src/Presentation/Web.Admin/Areas/Team/Views/Members/_PagedList.cshtml new file mode 100644 index 000000000..243f60910 --- /dev/null +++ b/Src/Presentation/Web.Admin/Areas/Team/Views/Members/_PagedList.cshtml @@ -0,0 +1,33 @@ +@using MvcPagedList.Core + +@PagedList.Pager(actionName: "search", controllerName: "Permissions", areaName: "Administration", + routeValues: new + { + + term = Context.Request.Query["term"], + groupName = Context.Request.Query["groupName"], + + }, + ajaxAttributes: new + { + data_ajax = "true", + data_ajax_loading = "#global-ajax-loading", + data_ajax_update = "#ajax-show-list", + data_ajax_method = "GET", + data_ajax_mode = "replace" + + + }, + pagerOptions: new PagerOptions + { + currentPage = (int)ViewBag.CurrentPage, + PageCount = (int)ViewBag.PageSize, + TotalItemCount = (int)ViewBag.TotalItemCount, + DisplayMode = PagedListDisplayMode.IfNeeded, + DisplayInfoArea = true, + LinkToNextPageFormat = "previous", + LinkToPreviousPageFormat = "next", + CurrentLocationFormat = "page", + PageCountFormat = "from", + TotalItemCountFormat = "total", + }) \ No newline at end of file diff --git a/Src/Presentation/Web.Admin/Views/Shared/Components/UserMenu/Default.cshtml b/Src/Presentation/Web.Admin/Views/Shared/Components/UserMenu/Default.cshtml new file mode 100644 index 000000000..eaaff4b2e --- /dev/null +++ b/Src/Presentation/Web.Admin/Views/Shared/Components/UserMenu/Default.cshtml @@ -0,0 +1,28 @@ +@model TaskoMask.Application.Core.Dtos.Common.Users.UserBasicInfoDto +@{ + var defaultUserImageUrl = Url.Content("~/content/img/default-user-avatar.jpg"); +} + \ No newline at end of file diff --git a/Src/Presentation/Web.Admin/Views/Shared/_AdminLayout.cshtml b/Src/Presentation/Web.Admin/Views/Shared/_AdminLayout.cshtml index b9c2ab070..ad57cb292 100644 --- a/Src/Presentation/Web.Admin/Views/Shared/_AdminLayout.cshtml +++ b/Src/Presentation/Web.Admin/Views/Shared/_AdminLayout.cshtml @@ -21,7 +21,7 @@ - @*@await Component.InvokeAsync(nameof(UserMenu))*@ + @await Component.InvokeAsync(nameof(UserMenu))