Example #1
0
        /// <summary>
        /// Delete sms
        /// </summary>
        /// <param name="Id"></param>
        public void DeleteSms(int Id)
        {
            SmsDomain smsDomain = _smsRepository.GetById(Id);

            if (smsDomain == null)
            {
                throw new NsiArgumentException(NotificationMessages.SmsWithIdDoesNotExists);
            }
            _smsRepository.Delete(smsDomain);
        }
        private async Task <Result> ProcessSms(UserDto currentUser, UserItemClientDto userItem)
        {
            Sms sms = await _smsRepository.GetById(userItem.ItemId);

            if (sms.Status == SmsStatus.Accepted)
            {
                _logger.Warning("SMS already accepted");
                return(Result.Failure(ErrorCodes.SMSAlreadyTaken));
            }

            var caseType = await _caseTypeRepository.GetById(userItem.CaseTypeId);

            if (caseType == null)
            {
                _logger.Warning($"CaseType with Id {userItem.CaseTypeId} not found");
                return(Result.Failure(ErrorCodes.CaseTypeNotFound));
            }

            Result <CaseFolder> result = AcceptSms(sms, caseType, currentUser.Id);

            if (result.IsFailure)
            {
                _logger.Warning($"Failed to receive SMS.. {result.ErrorMessage}");
                return(Result.Failure(result.ErrorCode));
            }

            var caseFolder = result.Value;
            await _caseFolderRepository.Add(caseFolder);

            await _unitOfWork.CommitAsync();

            await _phoneHubMessageService.NotifyUsersAboutAcceptedSms(caseFolder.Id, currentUser.Id);

            return(Result.Success());
        }
Example #3
0
        private async Task <bool> IsSmsInRepo(Guid resultItemId)
        {
            using var unitOfWork = _serviceProvider.GetService <UnitOfWork>();
            unitOfWork.Begin();
            var smsInInbox = await _smsRepository.GetById(resultItemId);

            if (smsInInbox == null)
            {
                return(false);
            }

            return(true);
        }