public void Handle(AddSharing command)
        {
            var sharing = _sharingFactory.Create();

            sharing.Recipient = _recipientRepository.Get(command.RecipientID);
            sharing.Selection = _selectionRepository.Get(command.SelectionID);
            sharing.UniqueID  = command.UniqueID;
            _unitOfWork.CommitChanges();
        }
Exemplo n.º 2
0
        public async Task <IActionResult> DeleteRecipient(long id)
        {
            var recipient = await _repository.Get(id);

            if (recipient == null)
            {
                return(NotFound());
            }

            _repository.Delete(recipient);
            await _repository.Save();

            return(NoContent());
        }
Exemplo n.º 3
0
        public void Handle(AddRecipientsSelections command)
        {
            List <Recipient> recipients = new List <Recipient>();
            List <Selection> selections = new List <Selection>();

            _validator.ToList().ForEach(x => x.Validate(command));
            foreach (var recipient in command.RecipientEmails)
            {
                if (!_recipientRepository.Exists(recipient))
                {
                    var newRecipient = new AddRecipient(recipient);
                    _commandHandlerDispatcher.Execute(newRecipient);
                    _unitOfWork.CommitChanges();
                }
                recipients.Add(_recipientRepository.Get(recipient));
            }

            foreach (var selection in command.SheetSelections)
            {
                var sheetName     = RegexUtils.GetSheetNameFromSelectionString(selection);
                var selectionName = RegexUtils.GetSelectionNameFromSelectionString(selection);
                if (!_selectionRepository.Exists(sheetName, selectionName))
                {
                    var newSelection = new AddSelection(sheetName, selectionName);
                    _commandHandlerDispatcher.Execute(newSelection);
                    _unitOfWork.CommitChanges();
                }
                selections.Add(_selectionRepository.Get(sheetName, selectionName));
            }

            foreach (var recipientEntity in recipients)
            {
                foreach (var selectionEntity in selections)
                {
                    if (!_sharingRepository.Exists(recipientEntity.ID, selectionEntity.ID))
                    {
                        var newSharing = new AddSharing(recipientEntity.ID, selectionEntity.ID);
                        _commandHandlerDispatcher.Execute(newSharing);
                        _unitOfWork.CommitChanges();
                    }
                }
            }
        }
Exemplo n.º 4
0
 public async Task <IEnumerable <Recipient> > Get()
 {
     return(await _repository.Get());
 }