Ejemplo n.º 1
0
        private async Task <AddKudosDto> MapInitialInfoToDtoAsync(AddKudosLogDto kudosLog, decimal?overridenPoints = null)
        {
            var sendingUser = await _usersDbSet.FindAsync(kudosLog.UserId);

            _kudosServiceValidator.ValidateUser(sendingUser);

            var kudosType = await _kudosTypesDbSet.AsNoTracking().FirstOrDefaultAsync(p => p.Id == kudosLog.PointsTypeId);

            _kudosServiceValidator.ValidateKudosType(kudosType);

            return(new AddKudosDto
            {
                KudosLog = kudosLog,
                KudosType = MapKudosTypesToDto(kudosType),
                SendingUser = _mapper.Map <ApplicationUserDto>(sendingUser),
                TotalKudosPointsInLog = overridenPoints ?? kudosLog.MultiplyBy * kudosType?.Value ?? 0,
                PictureId = kudosLog.PictureId
            });
        }
Ejemplo n.º 2
0
        private AddKudosDTO MapInitialInfoToDTO(AddKudosLogDTO kudosLog, decimal?overridenPoints = null)
        {
            var sendingUser = _usersDbSet.Find(kudosLog.UserId);

            _kudosServiceValidator.ValidateUser(sendingUser);

            var kudosType = _kudosTypesDbSet.Find(kudosLog.PointsTypeId);

            _kudosServiceValidator.ValidateKudosType(kudosType);

            return(new AddKudosDTO
            {
                KudosLog = kudosLog,
                KudosType = kudosType,
                SendingUser = sendingUser,
                TotalKudosPointsInLog = overridenPoints ?? kudosLog.MultiplyBy * kudosType.Value,
                PictureId = kudosLog.PictureId
            });
        }
Ejemplo n.º 3
0
        private AddKudosDTO MapInitialInfoToDTO(AddKudosLogDTO kudosLog, decimal?overridenPoints = null)
        {
            var sendingUser = _usersDbSet.Find(kudosLog.UserId);

            _kudosServiceValidator.ValidateUser(sendingUser);

            var kudosType = _kudosTypesDbSet.AsNoTracking().FirstOrDefault(p => p.Id == kudosLog.PointsTypeId);

            _kudosServiceValidator.ValidateKudosType(kudosType);

            return(new AddKudosDTO
            {
                KudosLog = kudosLog,
                KudosType = MapKudosTypesToDTO(kudosType),
                SendingUser = _mapper.Map <ApplicationUserDTO>(sendingUser),
                TotalKudosPointsInLog = overridenPoints ?? kudosLog.MultiplyBy * kudosType.Value,
                PictureId = kudosLog.PictureId
            });
        }