public async Task <ProducerData> HandleAsync(GetProducerForNotification message)
        {
            var producers = await repository.GetByNotificationId(message.NotificationId);

            var producer = producers.GetProducer(message.ProducerId);

            return(mapper.Map(producer, message.NotificationId));
        }
Exemplo n.º 2
0
        public async Task <IDocumentBlock> Create(Guid notificationId, IList <MergeField> mergeFields)
        {
            var notification = await notificationApplicationRepository.GetById(notificationId);

            var producer = await producerRepository.GetByNotificationId(notificationId);

            return(new ProducerBlock(mergeFields, notification, producer));
        }
Exemplo n.º 3
0
        public async Task <Guid> HandleAsync(SetSiteOfExport command)
        {
            var producers = await repository.GetByNotificationId(command.NotificationId);

            producers.SetProducerAsSiteOfExport(command.ProducerId);

            await context.SaveChangesAsync();

            return(command.NotificationId);
        }
        public async Task <bool> HandleAsync(DeleteProducerForNotification query)
        {
            var producers = await repository.GetByNotificationId(query.NotificationId);

            producers.RemoveProducer(query.ProducerId);

            await context.SaveChangesAsync();

            return(true);
        }
Exemplo n.º 5
0
        public IList <ProducerData> Map(Notification source)
        {
            var producerCollection = Task.Run(() => producerRepository.GetByNotificationId(source.Id)).Result;

            return(producerCollection.Producers.Select(p => new ProducerData
            {
                Address = addressMap.Map(p.Address),
                Business = businessMap.Map(p.Business),
                Contact = contactMap.Map(p.Contact),
                Id = p.Id,
                IsSiteOfExport = p.IsSiteOfExport,
                NotificationId = source.Id
            }).ToList());
        }
Exemplo n.º 6
0
        public async Task <Guid> HandleAsync(AddProducerToNotification command)
        {
            var country = await countryRepository.GetById(command.Address.CountryId.Value);

            var address  = ValueObjectInitializer.CreateAddress(command.Address, country.Name);
            var contact  = ValueObjectInitializer.CreateContact(command.Contact);
            var business = ProducerBusiness.CreateProducerBusiness(command.Business.Name, command.Business.BusinessType,
                                                                   command.Business.RegistrationNumber, command.Business.OtherDescription);

            var producers = await repository.GetByNotificationId(command.NotificationId);

            var producer = producers.AddProducer(business, address, contact);

            await context.SaveChangesAsync();

            return(producer.Id);
        }
        public async Task <Guid> HandleAsync(UpdateProducerForNotification message)
        {
            var country = await countryRepository.GetById(message.Address.CountryId.Value);

            var producers = await repository.GetByNotificationId(message.NotificationId);

            var business = ProducerBusiness.CreateProducerBusiness(message.Business.Name,
                                                                   message.Business.BusinessType,
                                                                   message.Business.RegistrationNumber,
                                                                   message.Business.OtherDescription);
            var address = ValueObjectInitializer.CreateAddress(message.Address, country.Name);
            var contact = ValueObjectInitializer.CreateContact(message.Contact);

            var producer = producers.GetProducer(message.ProducerId);

            producer.Address  = address;
            producer.Business = business;
            producer.Contact  = contact;

            await context.SaveChangesAsync();

            return(producer.Id);
        }