示例#1
0
        protected override void OnCommandDeleteExecute()
        {
            var result = _messageDialogService.ShowOkCancelDialog($"Do you really want to delete the Broker ?", "Delete");

            if (result == MessageDialogResult.OK)
            {
                _repository.Remove(CustomerBrokerWrapper.Entity);
                _repository.SaveAsync();

                RaiseEventAfterDetailDeleted(Id);
            }
        }
示例#2
0
        public async Task <Result> InitializeResult(string authToken, Result result, string userId)
        {
            result.FreelancerId = userId;
            result.State        = ResultStates.FilesUploaded;

            var exists = await _brokerRepository.GetByProjectId(result.ProjectId);

            if (exists != null)
            {
                throw new InvalidResult("Result already exists, cannot initialize");
            }

            var createdResult = await _brokerRepository.Create(result);

            if (createdResult != null)
            {
                try
                {
                    bool response = await _client.PostEvent(authToken, new EventData
                    {
                        Type      = "result",
                        OwnerId   = userId,
                        ProjectId = result.ProjectId,
                        Content   = JsonConvert.SerializeObject(new
                        {
                            ResultId  = createdResult.Id,
                            ProjectId = createdResult.ProjectId,
                            Status    = ResultStates.FilesUploaded
                        })
                    });

                    if (!response)
                    {
                        throw new InvalidResult("Service failed");
                    }
                }
                catch (Exception e)
                {
                    await _brokerRepository.Remove(createdResult);

                    throw new InvalidResult("Couldn't bind to service Collaboration: " + e.Message);
                }
            }

            return(createdResult ??
                   throw new InvalidResult());
        }
        public Task <bool> Handle(RemoveBrokerCommand message, CancellationToken cancellationToken)
        {
            if (!message.IsValid())
            {
                NotifyValidationErrors(message);
                return(Task.FromResult(false));
            }

            _brokerRepository.Remove(message.Id);

            if (Commit())
            {
                _bus.RaiseEvent(new BrokerRemovedEvent(message.Id));
            }

            return(Task.FromResult(true));
        }