public async Task AssociateProjectAndCategory(AssociationRequest associationRequest)
        {
            Category category = await EntityFrameworkQueryableExtensions.FirstOrDefaultAsync(context.Categories, c => c.Type == associationRequest.CategoryType &&
                                                                                             c.Name == associationRequest.CategoryName);

            if (category == null)
            {
                category = new Category()
                {
                    Type = associationRequest.CategoryType, Name = associationRequest.CategoryName
                };
                context.Categories.Add(category);
                await context.SaveChangesAsync();
            }

            Project project = await GetProjectAsync(associationRequest.ProjectID);

            ProjectCategory pc = new ProjectCategory()
            {
                Project = project, Category = category
            };

            context.ProjectCategories.Add(pc);
            await context.SaveChangesAsync();
        }
Exemple #2
0
        public AssociationRequest ReceiveAssociationRequest()
        {
            _associateRequestPDU = (AssociateRequestPDU)ReadNextPDU(DataUnitType.AssociateRequestPDU);
            var associationRequest = AssociationRequest.FromPDU(_associateRequestPDU);

            MaxDataTransferPDULengthRequestedByPeer = associationRequest.MaxDataTransferPDULength;
            return(associationRequest);
        }
Exemple #3
0
        public Task <IActionResult> FetchAvailableMatchDirectorByAssociation(AssociationRequest request)
        {
            //Recupero la lista dal layer
            var entities = BasicLayer.FetchAvailableMatchDirectorByAssociaitonId(request.AssociationId);

            //Ritorno i contratti
            return(Reply(entities.As(x => ContractUtils.GenerateContract(x))));
        }
        public async Task AssociateProjectWithCategory(AssociationRequest associationRequest)
        {
            //var token = await TryGetAccessToken();
            //httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Value);

            var json = new StringContent(JsonSerializer.Serialize(associationRequest), Encoding.UTF8, "application/json");

            await httpClient.PostAsync("api/project/associate", json);
        }
        public Task <IActionResult> GetAssociation(AssociationRequest request)
        {
            var entity = BasicLayer.GetAssociation(request.AssociationId);

            //verifico validità dell'entità
            if (entity == null)
            {
                return(Task.FromResult <IActionResult>(NotFound()));
            }

            //Serializzazione e conferma
            return(Reply(ContractUtils.GenerateContract(entity)));
        }
Exemple #6
0
        /// <summary>Connects to a remote application entity and establishes an association using the proposed presentation contexts</summary>
        public DicomAssociation ConnectTo(DicomNetworkAddress ae)
        {
            if (_presentationContextRequests.Count == 0)
            {
                throw new InvalidOperationException("Missing presentation context proposals");
            }

            var connection = DicomConnection.Connect(ae.HostNameOrIPAddress, ae.PortNumber, CancellationToken);

            try
            {
                connection.TraceWriter = TraceWriter;

                var associationRequest = new AssociationRequest
                {
                    CalledAETitle  = ae.AETitle,
                    CallingAETitle = AETitle,
                };

                associationRequest.PresentationContextRequests.AddRange(_presentationContextRequests);

                connection.SendAssociationRequest(associationRequest);

                var associationResponse = connection.ReceiveAssociationResponse();

                var presentationContextTransferSyntaxes = new Dictionary <byte, DicomUID>();

                foreach (var presentationContextResponse in associationResponse.PresentationContextResponses)
                {
                    var presentationContextID = presentationContextResponse.PresentationContextID;

                    if (presentationContextResponse.Result == PresentationContextResponse.ResultCode.Acceptance)
                    {
                        var transferSyntaxUID = presentationContextResponse.TransferSyntaxName;
                        presentationContextTransferSyntaxes[presentationContextID] = transferSyntaxUID;
                    }
                }

                return(new DicomAssociation(connection, presentationContextTransferSyntaxes));
            }
            catch (Exception)
            {
                connection.Dispose();
                throw;
            }
        }
        public async Task <IActionResult> DeleteAssociation([EntityId] AssociationRequest request)
        {
            //Recupero l'elemento dal business layer
            var entity = BasicLayer.GetAssociation(request.AssociationId);

            //Se l'utente non hai i permessi non posso rimuovere entità con userId nullo
            if (entity == null)
            {
                return(NotFound());
            }

            //Invocazione del service layer
            var validations = await BasicLayer.DeleteAssociation(entity, PlatformUtils.GetIdentityUserId(User));

            if (validations.Count > 0)
            {
                return(BadRequest(validations));
            }

            //Return contract
            return(Ok(ContractUtils.GenerateContract(entity)));
        }
Exemple #8
0
 public void SendAssociationRequest(AssociationRequest associationRequest) => SendPDU(associationRequest.ToPDU());
        //
        // GET: /Ims/Association/
        public ActionResult Index(AssociationRequest request)
        {
            var result = this.ImsService.GetAssociationList(request);

            return(View(result));
        }
Exemple #10
0
        public async Task <IActionResult> Associate(AssociationRequest associationRequest)
        {
            await repository.AssociateProjectAndCategory(associationRequest);

            return(NoContent());
        }