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 async Task CreateFacility(FacilityDto facilityDto) { var facility = _mapper.Map <Facility>(facilityDto); facility.Guid = Guid.NewGuid(); facility.CreationDate = DateTime.Now; _facilityRepository.Add(facility); await _facilityRepository.SaveChangesAsync(); }
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 Task <FacilityId> AddAsync( string name ) { return(CommandAsync( Authorize.Unauthenticated, () => { var facility = new Facility( name, new FacilityContact(null, null) ); _facilityRepo.Add(facility); return Task.FromResult(facility.Id); } )); }
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); }
/// <summary> /// /// </summary> /// <param name="request"></param> public async Task <FacilityEntity> SaveFacility(FacilityRequest request) { var facilityEntity = new FacilityEntity() { CreatedDate = DateTime.Now, CreatedBy = Admin.CreatedBy, Active = request.Active, LastModifiedBy = Admin.LastUpdatedBy, LastModifiedDate = DateTime.Now, ADUIgnoreCritLow = request.ADUIgnoreCritLow, ADUIgnoreStockOut = request.ADUIgnoreStockOut, ADUQtyRounding = request.ADUQtyRounding, FormularyId = request.FormularyId, Approved = request.Approved, FacilityId = request.FacilityId }; await _facilityRepository.Add(facilityEntity); await _unitOfWork.CommitChanges(); return(facilityEntity); }
public Facility Add(Facility model) { _repository.Add(model); return(model); }