public async Task <AccessPointIdentityQueryDTO> Handle(AccessPointIdentityQuery request, CancellationToken cancellationToken) { var acc = await accessPointRepository.FindAsync(request.Id); if (acc == null) { throw new HttpResourceNotFoundException(localizer["HttpRespond.NotFound", "AccessPoint", request.Id]); } var dto = AccessPointIdentityQueryDTO.From(acc); dto.Name = appLocalizer[dto.Name]; return(dto); }
public async Task <Unit> Handle(AccessPointPatchCommand request, CancellationToken cancellationToken) { var sysRoleId = identityService.GetUserRole(); if (!(sysRoleId == SystemRole.ApplicationManager.Id.ToString() || sysRoleId == SystemRole.ApplicationService.Id.ToString())) { throw new HttpForbiddenException(); } var accessPoint = await accessPointRepository.FindAsync(request.Id); mapper.Map(accessPoint, request); request.ApplyPatch(); //var existKey = await accessPointRepository.Get(new PointKeyUniqueCheckSpecification(request.PointKey, request.Id)).AnyAsync(); //if (existKey) // throw new HttpBadRequestException(commonLocalizer["FieldValueIsDuplicate", request.PointKey, "PointKey"]); accessPoint.UpdateBasicInfo(request.Name, request.PointKey, request.Description); await accessPointRepository.UpdateAsync(accessPoint); return(Unit.Value); }
public async Task <bool> ExitRecord(string id) { var data = await accessPointRepository.FindAsync(id); return(data != null); }