示例#1
0
        private void ValidateAvailableKudosThisMonth(AddKudosDTO kudosDTO, decimal totalKudosPointsInLog)
        {
            var timestaps = DateTime.UtcNow;

            var currentMonthSum = _kudosLogsDbSet
                                  .Where(l => l.CreatedBy == kudosDTO.SendingUser.Id &&
                                         l.Created.Month == timestaps.Month &&
                                         l.Created.Year == timestaps.Year &&
                                         l.KudosSystemType == ConstBusinessLayer.KudosTypeEnum.Send &&
                                         l.OrganizationId == kudosDTO.KudosLog.OrganizationId)
                                  .Select(p => p.Points)
                                  .DefaultIfEmpty(0)
                                  .Sum();

            currentMonthSum += kudosDTO.TotalPointsSent;

            _kudosServiceValidator.ValidateUserAvailableKudosToSendPerMonth(totalKudosPointsInLog, ConstBusinessLayer.KudosAvailableToSendThisMonth - currentMonthSum);
        }
示例#2
0
        private async Task ValidateAvailableKudosThisMonthAsync(AddKudosDto kudos, decimal totalKudosPointsInLog)
        {
            var timestamp = DateTime.UtcNow;

            var currentMonthSum = await _kudosLogsDbSet
                                  .Where(l => l.CreatedBy == kudos.SendingUser.Id &&
                                         l.Created.Month == timestamp.Month &&
                                         l.Created.Year == timestamp.Year &&
                                         l.KudosSystemType == KudosTypeEnum.Send &&
                                         l.OrganizationId == kudos.KudosLog.OrganizationId)
                                  .Select(p => p.Points)
                                  .DefaultIfEmpty(0)
                                  .SumAsync();

            currentMonthSum += kudos.TotalPointsSent;

            _kudosServiceValidator.ValidateUserAvailableKudosToSendPerMonth(totalKudosPointsInLog, BusinessLayerConstants.KudosAvailableToSendThisMonth - currentMonthSum);
        }