Skip to content

Commit

Permalink
add Members controller to admin panel and some dto and viewModel changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hamed-shirbandi committed Nov 9, 2021
1 parent 9478f6f commit b0135fa
Show file tree
Hide file tree
Showing 43 changed files with 586 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -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; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down
Original file line number Diff line number Diff line change
@@ -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; }

}
}
Original file line number Diff line number Diff line change
@@ -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; }

}
}
Original file line number Diff line number Diff line change
@@ -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; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
}
Original file line number Diff line number Diff line change
@@ -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; }
}
}
Original file line number Diff line number Diff line change
@@ -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<OrganizationBasicInfoDto> Organizations { get; set; }

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

namespace TaskoMask.Application.Core.ViewModels
{
public class OperatorDetailViewModel
public class OperatorDetailsViewModel
{
public OperatorDetailViewModel()
public OperatorDetailsViewModel()
{
Roles = new List<SelectListItem>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<RoleBasicInfoDto>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

namespace TaskoMask.Application.Core.ViewModels
{
public class RoleDetailViewModel
public class RoleDetailsViewModel
{
public RoleDetailViewModel()
public RoleDetailsViewModel()
{
Operators = new List<OperatorBasicInfoDto>();
Permissions = new Dictionary<string, IEnumerable<SelectListItem>>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public interface IOperatorService : IUserService
Task<Result<CommandResult>> UpdateAsync(OperatorUpsertDto input);
Task<Result<OperatorBasicInfoDto>> GetByIdAsync(string id);
Task<Result<IEnumerable<OperatorOutputDto>>> GetListAsync();
Task<Result<OperatorDetailViewModel>> GetDetailsAsync(string id);
Task<Result<OperatorDetailsViewModel>> GetDetailsAsync(string id);
Task<Result<CommandResult>> UpdateRolesAsync(string id, string[] rolesId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,15 @@ public async Task<Result<IEnumerable<OperatorOutputDto>>> GetListAsync()
/// <summary>
///
/// </summary>
public async Task<Result<OperatorDetailViewModel>> GetDetailsAsync(string id)
public async Task<Result<OperatorDetailsViewModel>> GetDetailsAsync(string id)
{
var @operator = await _operatorRepository.GetByIdAsync(id);
if (@operator == null)
return Result.Failure<OperatorDetailViewModel>(message: string.Format(ApplicationMessages.Data_Not_exist, DomainMetadata.Operator));
return Result.Failure<OperatorDetailsViewModel>(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<OperatorUpsertDto>(@operator),
Roles = roles.Select(role => new SelectListItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public interface IPermissionService : IBaseService
Task<Result<CommandResult>> UpdateAsync(PermissionUpsertDto input);

Task<Result<PermissionBasicInfoDto>> GetByIdAsync(string id);
Task<Result<PermissionDetailViewModel>> GetDetailsAsync(string id);
Task<Result<PermissionDetailsViewModel>> GetDetailsAsync(string id);
Task<Result<IEnumerable<PermissionBasicInfoDto>>> GetListAsync(string id);
Task<Result<IEnumerable<PermissionBasicInfoDto>>> GetListByIdsAsync(string[] ids);
Task<Result<string[]>> GetSystemNameListByOperatorAsync(string userName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,17 @@ public async Task<Result<PermissionBasicInfoDto>> GetByIdAsync(string id)
/// <summary>
///
/// </summary>
public async Task<Result<PermissionDetailViewModel>> GetDetailsAsync(string id)
public async Task<Result<PermissionDetailsViewModel>> GetDetailsAsync(string id)
{
var permission = await _permissionRepository.GetByIdAsync(id);
if (permission == null)
return Result.Failure<PermissionDetailViewModel>(message: string.Format(ApplicationMessages.Data_Not_exist, DomainMetadata.Permission));
return Result.Failure<PermissionDetailsViewModel>(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<PermissionUpsertDto>(permission),
Roles = _mapper.Map<IEnumerable<RoleBasicInfoDto>>(roles)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public interface IRoleService : IBaseService
Task<Result<CommandResult>> CreateAsync(RoleUpsertDto input);
Task<Result<CommandResult>> UpdateAsync(RoleUpsertDto input);
Task<Result<CommandResult>> UpdatePermissionsAsync(string id, string[]permissionsId);
Task<Result<RoleDetailViewModel>> GetDetailsAsync(string id);
Task<Result<RoleDetailsViewModel>> GetDetailsAsync(string id);
Task<Result<RoleBasicInfoDto>> GetByIdAsync(string id);
Task<Result<IEnumerable<RoleOutputDto>>> GetListAsync();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,18 @@ public async Task<Result<IEnumerable<RoleOutputDto>>> GetListAsync()
/// <summary>
///
/// </summary>
public async Task<Result<RoleDetailViewModel>> GetDetailsAsync(string id)
public async Task<Result<RoleDetailsViewModel>> GetDetailsAsync(string id)
{
var role = await _roleRepository.GetByIdAsync(id);
if (role == null)
return Result.Failure<RoleDetailViewModel>(message: string.Format(ApplicationMessages.Data_Not_exist, DomainMetadata.Role));
return Result.Failure<RoleDetailsViewModel>(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<RoleUpsertDto>(role),
Operators = _mapper.Map<IEnumerable<OperatorBasicInfoDto>>(operators),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -12,6 +13,7 @@ public interface IMemberService : IUserService
Task<Result<CommandResult>> CreateAsync(MemberRegisterDto input);
Task<Result<CommandResult>> UpdateAsync(UserUpsertDto input);
Task<Result<MemberBasicInfoDto>> GetByIdAsync(string id);
Task<Result<bool>> ValidateUserPasswordAsync(string userName,string password);
Task<Result<PublicPaginatedListReturnType<MemberOutputDto>>> SearchAsync(int page, int recordsPerPage, string term);
Task<Result<MemberDetailsViewModel>> GetDetailsAsync(string id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -67,6 +69,41 @@ public async Task<Result<MemberBasicInfoDto>> GetByIdAsync(string id)



/// <summary>
///
/// </summary>
public async Task<Result<PublicPaginatedListReturnType<MemberOutputDto>>> SearchAsync(int page, int recordsPerPage, string term)
{
return await SendQueryAsync(new SearchMembersQuery(page, recordsPerPage, term));

}



/// <summary>
///
/// </summary>
public async Task<Result<MemberDetailsViewModel>> GetDetailsAsync(string id)
{
var memberQueryResult = await SendQueryAsync(new GetMemberByIdQuery(id));
if (!memberQueryResult.IsSuccess)
return Result.Failure<MemberDetailsViewModel>(memberQueryResult.Errors);


var organizationQueryResult = await SendQueryAsync(new GetOrganizationsByOwnerMemberIdQuery(memberQueryResult.Value.Id));
if (!organizationQueryResult.IsSuccess)
return Result.Failure<MemberDetailsViewModel>(organizationQueryResult.Errors);


var projectDetail = new MemberDetailsViewModel
{
Member = memberQueryResult.Value,
Organizations = organizationQueryResult.Value,
};

return Result.Success(projectDetail);
}


#endregion
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Invitation>, IInvitationRepository
{
#region Fields

private readonly IMongoCollection<Invitation> _invitations;

#endregion

#region Ctors

public InvitationRepository(IMongoDbContext dbContext) : base(dbContext)
{
_invitations = dbContext.GetCollection<Invitation>();
}





#endregion

#region Public Methods

public async Task<int> OrganizationsCountByInvitedMemberIdAsync(string invitedMemberId)
{
return await _invitations.AsQueryable()
.Where(i => i.InvitedMemberId == invitedMemberId)
.Select(i => i.OrganizationId).Distinct().CountAsync();
}



#endregion

#region Private Methods



#endregion

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public OrganizationRepository(IMongoDbContext dbContext) : base(dbContext)
_organizations = dbContext.GetCollection<Organization>();
}



#endregion

#region Public Methods
Expand All @@ -48,6 +50,17 @@ public async Task<IEnumerable<Organization>> GetListByOwnerMemberIdAsync(string
return await _organizations.AsQueryable().Where(o => o.OwnerMemberId == ownerMemberId).ToListAsync();
}



/// <summary>
///
/// </summary>
public async Task<long> CountByOwnerMemberIdAsync(string ownerMemberId)
{
return await _organizations.CountDocumentsAsync(o => o.OwnerMemberId== ownerMemberId);
}


#endregion

#region Private Methods
Expand Down
Loading

0 comments on commit b0135fa

Please sign in to comment.