public async Task <Guid> HandleAsync(CreateLegacyNotificationApplication message) { var notification = await notificationApplicationFactory.CreateLegacy( message.NotificationType, message.CompetentAuthority, message.Number); notificationApplicationRepository.Add(notification); await context.SaveChangesAsync(); var facilityCollection = new FacilityCollection(notification.Id); var carrierCollection = new CarrierCollection(notification.Id); var producerCollection = new ProducerCollection(notification.Id); facilityRepository.Add(facilityCollection); carrierRepository.Add(carrierCollection); producerRepository.Add(producerCollection); await context.SaveChangesAsync(); return(notification.Id); }
public ActionResult Create(ProducerEditModel producer) { if (ModelState.IsValid) { producerRepository.Add(producer.ToEntity(null)); using (UnitOfWork) { UnitOfWork.Commit(); } return(RedirectToAction("index")); } return(View(producer)); }
public async Task <bool> HandleAsync(CompleteDraftImportNotification message) { var draft = await draftImportNotificationRepository.Get(message.ImportNotificationId); var assessment = await importNotificationAssessmentRepository.GetByNotification(message.ImportNotificationId); var result = await importNotificationValidator.ValidateAsync(draft); if (result.IsValid && assessment.Status == ImportNotificationStatus.NotificationReceived) { var notification = await importNotificationRepository.Get(message.ImportNotificationId); var exporter = mapper.Map <Exporter>(draft.Exporter); var facilityCollection = mapper.Map <FacilityCollection>(draft.Facilities, draft.Preconsented); var importer = mapper.Map <Importer>(draft.Importer); var producer = mapper.Map <Producer>(draft.Producer); var shipment = mapper.Map <Shipment>(draft.Shipment, draft.Preconsented); var transportRoute = new Domain.ImportNotification.TransportRoute(message.ImportNotificationId, mapper.Map <StateOfExport>(draft.StateOfExport), mapper.Map <StateOfImport>(draft.StateOfImport)); if (!draft.TransitStates.HasNoTransitStates) { transportRoute.SetTransitStates( new TransitStateList(draft.TransitStates.TransitStates.Select(t => mapper.Map <TransitState>(t)))); } var wasteOperation = mapper.Map <WasteOperation>(draft.WasteOperation, notification); var wasteType = mapper.Map <Domain.ImportNotification.WasteType>(draft.WasteType, draft.ChemicalComposition.Composition); exporterRepository.Add(exporter); facilityRepository.Add(facilityCollection); importerRepository.Add(importer); producerRepository.Add(producer); shipmentRepository.Add(shipment); transportRouteRepository.Add(transportRoute); wasteOperationRepository.Add(wasteOperation); wasteTypeRepository.Add(wasteType); assessment.Submit(); await context.SaveChangesAsync(); } return(result.IsValid); }
public async Task <Guid> HandleAsync(CreateNotificationApplication command) { var authority = command.CompetentAuthority; var notification = await notificationApplicationFactory.CreateNew(command.NotificationType, authority); notificationApplicationRepository.Add(notification); await context.SaveChangesAsync(); var facilityCollection = new FacilityCollection(notification.Id); var carrierCollection = new CarrierCollection(notification.Id); var producerCollection = new ProducerCollection(notification.Id); facilityRepository.Add(facilityCollection); carrierRepository.Add(carrierCollection); producerRepository.Add(producerCollection); await context.SaveChangesAsync(); return(notification.Id); }
public void Add(Producer producer) { _producerRepository.Add(producer); }