Exemplo n.º 1
0
        public DocumentTypeType(
            DocumentRepository documentRepository,
            DocumentTypeRepository documentTypeRepository
            )
        {
            Field(x => x.Id, type: typeof(IdGraphType));
            Field(x => x.Name);
            Field(x => x.DisplayName);

            Field <ListGraphType <DocumentType> >(
                "documents",
                resolve: context => documentRepository.GetByDocumentTypeId(context.Source.Id)
                );

            //// Async test
            //FieldAsync<ListGraphType<DocumentType>>(
            //    "documents",
            //    resolve: async context =>
            //    {
            //        return await context.TryAsyncResolve(
            //            async c => await documentRepository.GetByDocumentTypeIdAsync(context.Source.Id)
            //        );
            //    }
            //);

            Field(x => x.CreatedByUserId, type: typeof(IdGraphType));
            // TODO: Field(x => x.CreatedByUser, type: typeof(UserType));
            Field(x => x.ModifiedByUserId, type: typeof(IdGraphType));
            // TODO: Field(x => x.ModifiedByUser, type: typeof(UserType));
        }
Exemplo n.º 2
0
 public UnitOfWork(ApplicationDbContext context)
 {
     _context          = context;
     OrganizationUnits = new OrganizationUnitRepository(context);
     DocumentTypes     = new DocumentTypeRepository(context);
     Documents         = new DocumentRepository(context);
 }
        public void A_ChangedDocumenType_modifies_Existing_country_in_the_database()
        {
            var bootStrapper = new BootStrapper();
            bootStrapper.StartServices();
            var serviceEvents = bootStrapper.GetService<IServiceEvents>();
            //1.- Create message
            var aggr = GenerateRandomAggregate();

            //2.- Create the tuple in the database
            var repository = new DocumentTypeRepository(_configuration.TestServer);
            repository.Insert(aggr);

            //3.- Change the aggregate
            aggr.CountryId = Guid.NewGuid();
            aggr.NameKeyId = StringExtension.RandomString(10);
            aggr.SapCode = StringExtension.RandomString(2);

            //4.- Emit message
            var message = GenerateMessage(aggr);
            message.MessageType = typeof(ChangedDocumentType).Name;
            serviceEvents.AddIncommingEvent(new IncommingEvent { @event = message });

            //5.- Load the saved country
            var documentType = repository.Get(aggr.Id);
            //6.- Check equality
            Assert.True(ObjectExtension.AreEqual(aggr, documentType));
        }
Exemplo n.º 4
0
        /// <summary>
        /// The constructor of the Document business logic layer.
        /// </summary>
        public DocumentBLL(
            IConfiguration configuration,
            ILogger <DocumentBLL> logger,
            IHttpContextAccessor httpContextAccessor,
            UserManager <User> userManager,
            FileService fileService,
            RabbitMQService rabbitMQService,
            DocumentRepository documentRepository,
            DocumentTypeRepository documentTypeRepository,
            ResumeBLL resumeBLL,
            ResumeRepository resumeRepository,
            DocumentResumeRepository documentResumeRepository
            )
        {
            this.configuration       = configuration;
            this.logger              = logger;
            this.httpContextAccessor = httpContextAccessor;

            this.userManager     = userManager;
            this.fileService     = fileService;
            this.rabbitMQService = rabbitMQService;

            this.documentRepository     = documentRepository;
            this.documentTypeRepository = documentTypeRepository;

            this.resumeBLL                = resumeBLL;
            this.resumeRepository         = resumeRepository;
            this.documentResumeRepository = documentResumeRepository;
        }
Exemplo n.º 5
0
 public UnitOfWork(FactoringContext context)
 {
     _context                     = context;
     CompanyRespository           = new CompanyRepository(_context);
     RepresentivePeopleRepository = new RepresentivePeopleRepository(_context);
     BussinessTypeRepository      = new BussinessTypeRepository(_context);
     CountryRepository            = new CountryRepository(_context);
     SocialStatusRepository       = new SocialStatusRepository(_context);
     PersonStatusRepository       = new PersonStatusRepository(_context);
     DocumentTypeRepository       = new DocumentTypeRepository(_context);
 }
 public void A_RegisteredDocumenType_creates_a_new_currency_in_the_database()
 {
     var bootStrapper = new BootStrapper();
     bootStrapper.StartServices();
     var serviceEvents = bootStrapper.GetService<IServiceEvents>();
     //1.- Create message
     var aggr = GenerateRandomAggregate();
     var message = GenerateMessage(aggr);
     //2.- Emit message
     serviceEvents.AddIncommingEvent(new IncommingEvent { @event = message });
     //3.- Load the saved country
     var repository = new DocumentTypeRepository(_configuration.TestServer);
     var documentType = repository.Get(aggr.Id);
     //4.- Check equality
     Assert.True(ObjectExtension.AreEqual(aggr, documentType));
 }
Exemplo n.º 7
0
        public void CreateProduct(NewProductViewModel product, int CurrentUserID)
        {
            GenericRepository <Product> ProductRepository;
            GenericRepository <DAL.AppData.ProductType> ProductTypeRepository;
            GenericRepository <Document>     DocumentRepository;
            GenericRepository <DocumentType> DocumentTypeRepository;
            GenericRepository <User>         UserRepository;

            try
            {
                using (UnitOfWork unitOfWork = new UnitOfWork())
                {
                    DocumentRepository     = unitOfWork.GetRepoInstance <Document>();
                    ProductRepository      = unitOfWork.GetRepoInstance <Product>();
                    ProductTypeRepository  = unitOfWork.GetRepoInstance <DAL.AppData.ProductType>();
                    DocumentTypeRepository = unitOfWork.GetRepoInstance <DocumentType>();
                    UserRepository         = unitOfWork.GetRepoInstance <User>();
                    Product prdct = new Product();

                    prdct.ProductName = product.ProductName;
                    prdct.Code        = "";//need to generate
                    prdct.Description = product.Description;
                    prdct.Price       = Convert.ToDecimal(product.Price);
                    //owner
                    //prdct.Owner = UserRepository.GetByID(CurrentUserID);
                    //803 taking input from User not hard corded one
                    prdct.ProductType = ProductTypeRepository.GetByID((long)EProductType.Inventatory);
                    prdct.Quanity     = Convert.ToInt32(product.Quantity);
                    ProductRepository.Insert(prdct);
                    foreach (DocumentViewModel Dviewmodel in product.Documents)
                    {
                        Document dcment = new Document();
                        dcment.ServerPath    = Dviewmodel.DocumentPath;
                        dcment.FileExtension = Dviewmodel.MIMEType;
                        dcment.DocumentType  = DocumentTypeRepository.GetByID((long)EDocumentType.ProfilePhoto);
                        dcment.Products.Add(prdct);
                        DocumentRepository.Insert(dcment);
                    }
                    unitOfWork.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteErrorLog(ex);
            }
        }
        public void CreateTest()
        {
            //Arrange
            DocumentTypeRepository db = new DocumentTypeRepository("Data Source=localhost,32768;Initial Catalog=ISOSA_SARH;Integrated Security=False;Persist Security Info=False;User ID=sa;Password=Testing!");

            db.Create(new Domain.Catalog.DocumentType()
            {
                Description = "Identificación Oficial (INE)"
            });


            //Act
            var result = db.GetAll();


            //Assert
            Assert.AreNotEqual(null, result);
        }
        public void A_UnregisteredDocumenType_modifies_Existing_country_in_the_database()
        {
            var bootStrapper = new BootStrapper();
            bootStrapper.StartServices();
            var serviceEvents = bootStrapper.GetService<IServiceEvents>();
            //1.- Create message
            var aggr = GenerateRandomAggregate();

            //2.- Create the tuple in the database
            var repository = new DocumentTypeRepository(_configuration.TestServer);
            repository.Insert(aggr);

            //2.- Emit message
            var message = GenerateMessage(aggr);
            message.MessageType = typeof(UnregisteredDocumentType).Name;
            serviceEvents.AddIncommingEvent(new IncommingEvent { @event = message });

            var country = repository.Get(aggr.Id);
            Assert.Null(country);
        }
        public DocumentTypeListResponse FindAll()
        {
            DocumentTypeListResponse documentTypeListResponse = new DocumentTypeListResponse();

            IList <DocumentType> documentTypes = DocumentTypeRepository.FindAll().OrderBy(dt => dt.Name).ToList();

            if (documentTypes.IsEmpty())
            {
                documentTypeListResponse.Message = "Nenhum modelo encontrado";
                documentTypeListResponse.Success = false;

                return(documentTypeListResponse);
            }

            documentTypeListResponse.Message       = "Modelos encontrados com sucesso";
            documentTypeListResponse.Success       = true;
            documentTypeListResponse.DocumentTypes = documentTypes;

            return(documentTypeListResponse);
        }
        public DocumentTypeResponse Find(Guid id)
        {
            DocumentType documentType = DocumentTypeRepository.Find(id);

            if (documentType == null)
            {
                return(new DocumentTypeResponse {
                    Success = false, Message = "Modelo não encontrado"
                });
            }

            DocumentTypeResponse documentTypeResponse = new DocumentTypeResponse
            {
                Message      = "Modelo encontrado com sucesso",
                Success      = true,
                DocumentType = documentType
            };

            return(documentTypeResponse);
        }
        /// <summary>
        /// Create a new DocumentType.
        /// </summary>
        /// <param name="request">request information.</param>
        public BasicResponse Create(DocumentTypeCreateRequest request)
        {
            try
            {
                if (request == null)
                {
                    throw new DocJurException("Dados de request foram enviadas no formato incorreto.");
                }
                DocumentType documentType = new DocumentType
                {
                    Name    = request.Name,
                    Content = request.Content
                };

                DocumentTypeRepository.Add(documentType);

                request.Fields.ForEach(field =>
                {
                    DocumentTypeField documentTypeField = new DocumentTypeField
                    {
                        Name         = field.Name,
                        Label        = field.Label,
                        DocumentType = documentType,
                        FieldType    = field.FieldType
                    };

                    DocumentTypeFieldRepository.Add(documentTypeField);
                });

                return(new BasicResponse {
                    Success = true, Message = "Modelo criado com sucesso."
                });
            }
            catch (Exception e)
            {
                return(new BasicResponse {
                    Success = false, Message = e.Message
                });
            }
        }
Exemplo n.º 13
0
        public BasicResponse Create(DocumentCreateRequest request)
        {
            try
            {
                DocumentType documentType = DocumentTypeRepository.Find(request.DocumentTypeId);
                User         user         = UserRepository.Find(request.UserId);

                if (documentType == null)
                {
                    return(new BasicResponse {
                        Success = false, Message = $"Nenhum tipo de documento encontrado para o Id {request.DocumentTypeId}"
                    });
                }
                if (user == null)
                {
                    return(new BasicResponse {
                        Success = false, Message = $"Nenhum usuário encontrado para o Id {request.DocumentTypeId}"
                    });
                }

                Document document = new Document(documentType, user);
                request.Fields.ForEach(field =>
                {
                    document.Content = document.Content = document.Content.Replace($"[{field.Name}]", field.Value);
                });
                DocumentRepository.Add(document);

                return(new BasicResponse {
                    Success = true, Message = "Documento criado com sucesso."
                });
            }
            catch (Exception e)
            {
                return(new BasicResponse {
                    Success = false, Message = $"Erro inesperado: {e.Message}"
                });
            }
        }
Exemplo n.º 14
0
        public RJMQuery(
            DocumentRepository documentRepository,
            DocumentTypeRepository documentTypeRepository,
            ResumeRepository resumeRepository,
            ResumeStateRepository resumeStateRepository,
            SkillRepository skillRepository,
            SkillAliasRepository skillAliasRepository,
            JobRepository jobRepository,
            JobStateRepository jobStateRepository
            )
        {
            this.AuthorizeWith("Authorized");

            // Documents

            Field <ListGraphType <DocumentType> >(
                "documents",
                resolve: context => documentRepository.Get(null, x => x.OrderByDescending(x => x.ModifiedOn))
                );

            //// Async test
            //FieldAsync<ListGraphType<DocumentType>>(
            //    "documents",
            //    resolve: async context =>
            //    {
            //        return await context.TryAsyncResolve(
            //            async c => await documentRepository.GetAsync(null, x => x.OrderByDescending(x => x.ModifiedOn))
            //        );
            //    }
            //);

            Field <DocumentType>(
                "document",
                arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "id"
            }),
                resolve: context => documentRepository.GetById(context.GetArgument <Guid>("id"))
                );

            //// Async test
            //FieldAsync<DocumentType>(
            //    "document",
            //    arguments: new QueryArguments(new QueryArgument<NonNullGraphType<IdGraphType>> { Name = "id" }),
            //    resolve: async context =>
            //    {
            //        return await context.TryAsyncResolve(
            //            async c => await documentRepository.GetByIdAsync(context.GetArgument<Guid>("id"))
            //        );
            //    }
            //);

            // DocumentTypes

            Field <ListGraphType <DocumentTypeType> >(
                "documentTypes",
                resolve: context => documentTypeRepository.Get(null, x => x.OrderByDescending(x => x.ModifiedOn))
                );

            //// Async test
            //FieldAsync<ListGraphType<DocumentTypeType>>(
            //    "documentTypes",
            //    resolve: async context =>
            //    {
            //        return await context.TryAsyncResolve(
            //            async c => await documentTypeRepository.GetAsync(null, x => x.OrderByDescending(x => x.ModifiedOn))
            //        );
            //    }
            //);

            Field <DocumentTypeType>(
                "documentType",
                arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "id"
            }),
                resolve: context => documentTypeRepository.GetById(context.GetArgument <Guid>("id"))
                );

            //// Async test
            //FieldAsync<DocumentTypeType>(
            //    "documentType",
            //    arguments: new QueryArguments(new QueryArgument<NonNullGraphType<IdGraphType>> { Name = "id" }),
            //    resolve: async context =>
            //    {
            //        return await context.TryAsyncResolve(
            //            async c => await documentTypeRepository.GetByIdAsync(context.GetArgument<Guid>("id"))
            //        );
            //    }
            //);

            // Resumes

            Field <ListGraphType <ResumeType> >(
                "resumes",
                resolve: context => resumeRepository.Get(null, x => x.OrderByDescending(x => x.ModifiedOn))
                );

            //// Async test
            //FieldAsync<ListGraphType<ResumeType>>(
            //    "resumes",
            //    resolve: async context =>
            //    {
            //        return await context.TryAsyncResolve(
            //            async c => await resumeRepository.GetAsync(null, x => x.OrderByDescending(x => x.ModifiedOn))
            //        );
            //    }
            //);

            Field <ResumeType>(
                "resume",
                arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "id"
            }),
                resolve: context => resumeRepository.GetById(context.GetArgument <Guid>("id"))
                );

            //// Async test
            //FieldAsync<ResumeType>(
            //    "resume",
            //    arguments: new QueryArguments(new QueryArgument<NonNullGraphType<IdGraphType>> { Name = "id" }),
            //    resolve: async context =>
            //    {
            //        return await context.TryAsyncResolve(
            //            async c => await resumeRepository.GetByIdAsync(context.GetArgument<Guid>("id"))
            //        );
            //    }
            //);

            // ResumeStates

            Field <ListGraphType <ResumeStateType> >(
                "resumeStates",
                resolve: context => resumeStateRepository.Get(null, x => x.OrderByDescending(x => x.ModifiedOn))
                );

            //// Async test
            //FieldAsync<ListGraphType<ResumeStateType>>(
            //    "resumeStates",
            //    resolve: async context =>
            //    {
            //        return await context.TryAsyncResolve(
            //            async c => await resumeStateRepository.GetAsync(null, x => x.OrderByDescending(x => x.ModifiedOn))
            //        );
            //    }
            //);

            Field <ResumeStateType>(
                "resumeState",
                arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "id"
            }),
                resolve: context => resumeStateRepository.GetById(context.GetArgument <Guid>("id"))
                );

            //// Async test
            //FieldAsync<ResumeStateType>(
            //    "resumeState",
            //    arguments: new QueryArguments(new QueryArgument<NonNullGraphType<IdGraphType>> { Name = "id" }),
            //    resolve: async context =>
            //    {
            //        return await context.TryAsyncResolve(
            //            async c => await resumeStateRepository.GetByIdAsync(context.GetArgument<Guid>("id"))
            //        );
            //    }
            //);

            // Skills

            Field <ListGraphType <SkillType> >(
                "skills",
                resolve: context => skillRepository.Get(null, x => x.OrderByDescending(x => x.ModifiedOn))
                );

            //// Async test
            //FieldAsync<ListGraphType<SkillType>>(
            //    "skills",
            //    resolve: async context =>
            //    {
            //        return await context.TryAsyncResolve(
            //            async c => await skillRepository.GetAsync(null, x => x.OrderByDescending(x => x.ModifiedOn))
            //        );
            //    }
            //);

            Field <SkillType>(
                "skill",
                arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "id"
            }),
                resolve: context => skillRepository.GetById(context.GetArgument <Guid>("id"))
                );

            //// Async test
            //FieldAsync<SkillType>(
            //    "skill",
            //    arguments: new QueryArguments(new QueryArgument<NonNullGraphType<IdGraphType>> { Name = "id" }),
            //    resolve: async context =>
            //    {
            //        return await context.TryAsyncResolve(
            //            async c => await skillRepository.GetByIdAsync(context.GetArgument<Guid>("id"))
            //        );
            //    }
            //);

            // SkillAliases

            Field <ListGraphType <SkillAliasType> >(
                "skillAliases",
                resolve: context => skillAliasRepository.Get(null, x => x.OrderByDescending(x => x.ModifiedOn))
                );

            //// Async test
            //FieldAsync<ListGraphType<SkillAliasType>>(
            //    "skillAliases",
            //    resolve: async context =>
            //    {
            //        return await context.TryAsyncResolve(
            //            async c => await skillAliasRepository.GetAsync(null, x => x.OrderByDescending(x => x.ModifiedOn))
            //        );
            //    }
            //);

            Field <SkillAliasType>(
                "skillAlias",
                arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "id"
            }),
                resolve: context => skillAliasRepository.GetById(context.GetArgument <Guid>("id"))
                );

            //// Async test
            //FieldAsync<SkillAliasType>(
            //    "skillAlias",
            //    arguments: new QueryArguments(new QueryArgument<NonNullGraphType<IdGraphType>> { Name = "id" }),
            //    resolve: async context =>
            //    {
            //        return await context.TryAsyncResolve(
            //            async c => await skillAliasRepository.GetByIdAsync(context.GetArgument<Guid>("id"))
            //        );
            //    }
            //);

            // Jobs

            Field <ListGraphType <JobType> >(
                "jobs",
                resolve: context => jobRepository.Get(null, x => x.OrderByDescending(x => x.ModifiedOn))
                );

            //// Async test
            //FieldAsync<ListGraphType<JobType>>(
            //    "jobs",
            //    resolve: async context =>
            //    {
            //        return await context.TryAsyncResolve(
            //            async c => await jobRepository.GetAsync(null, x => x.OrderByDescending(x => x.ModifiedOn))
            //        );
            //    }
            //);

            Field <JobType>(
                "job",
                arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "id"
            }),
                resolve: context => jobRepository.GetById(context.GetArgument <Guid>("id"))
                );

            //// Async test
            //FieldAsync<JobType>(
            //    "job",
            //    arguments: new QueryArguments(new QueryArgument<NonNullGraphType<IdGraphType>> { Name = "id" }),
            //    resolve: async context =>
            //    {
            //        return await context.TryAsyncResolve(
            //            async c => await jobRepository.GetByIdAsync(context.GetArgument<Guid>("id"))
            //        );
            //    }
            //);

            // JobStates

            Field <ListGraphType <JobStateType> >(
                "jobStates",
                resolve: context => jobStateRepository.Get(null, x => x.OrderByDescending(x => x.ModifiedOn))
                );

            //// Async test
            //FieldAsync<ListGraphType<JobStateType>>(
            //    "jobStates",
            //    resolve: async context =>
            //    {
            //        return await context.TryAsyncResolve(
            //            async c => await jobStateRepository.GetAsync(null, x => x.OrderByDescending(x => x.ModifiedOn))
            //        );
            //    }
            //);

            Field <JobStateType>(
                "jobState",
                arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "id"
            }),
                resolve: context => jobStateRepository.GetById(context.GetArgument <Guid>("id"))
                );

            //// Async test
            //FieldAsync<JobStateType>(
            //    "jobState",
            //    arguments: new QueryArguments(new QueryArgument<NonNullGraphType<IdGraphType>> { Name = "id" }),
            //    resolve: async context =>
            //    {
            //        return await context.TryAsyncResolve(
            //            async c => await jobStateRepository.GetByIdAsync(context.GetArgument<Guid>("id"))
            //        );
            //    }
            //);
        }
Exemplo n.º 15
0
 public DocumentTypeService()
 {
     _repository = new DocumentTypeRepository();
 }
Exemplo n.º 16
0
 /// <summary>
 /// The constructor of the DocumentType business logic layer.
 /// </summary>
 public DocumentTypeBLL(
     DocumentTypeRepository documentTypeRepository
     )
 {
     this.documentTypeRepository = documentTypeRepository;
 }
Exemplo n.º 17
0
        public DocumentType(
            DocumentTypeRepository documentTypeRepository,
            DocumentRepository documentRepository,
            ResumeRepository resumeRepository,
            DocumentResumeRepository documentResumeRepository
            )
        {
            Field(x => x.Id, type: typeof(IdGraphType));
            Field(x => x.Name);
            Field(x => x.DisplayName, nullable: true);
            Field(x => x.Description, nullable: true);
            Field(x => x.Path, nullable: true);
            Field(x => x.URL, nullable: true);
            Field(x => x.SizeInBytes, nullable: true);
            Field(x => x.FileLastModifiedOn, nullable: true);
            Field(x => x.MimeType, nullable: true);

            Field <DocumentTypeType>(
                "documentType",
                resolve: context =>
            {
                if (context.Source.DocumentTypeId != null)
                {
                    return(documentTypeRepository.GetById((Guid)context.Source.DocumentTypeId));
                }
                return(null);
            }
                );

            //// Async test
            //FieldAsync<DocumentTypeType>(
            //    "documentType",
            //    resolve: async context =>
            //    {
            //        if (context.Source.DocumentTypeId != null) {
            //            return await context.TryAsyncResolve(
            //                async c => await documentTypeRepository.GetByIdAsync((Guid)context.Source.DocumentTypeId)
            //            );
            //        }
            //
            //        return null;
            //    }
            //);

            Field <ListGraphType <ResumeType> >(
                "resumes",
                resolve: context => resumeRepository.GetByDocumentId(context.Source.Id)
                );

            //// Async test
            //FieldAsync<ListGraphType<ResumeType>>(
            //    "resumes",
            //    resolve: async context =>
            //    {
            //        return await context.TryAsyncResolve(
            //            async c => await resumeRepository.GetByDocumentIdAsync(context.Source.Id)
            //        );
            //    }
            //);

            Field(x => x.CreatedByUserId, type: typeof(IdGraphType));
            // TODO: Field(x => x.CreatedByUser, type: typeof(UserType));
            Field(x => x.ModifiedByUserId, type: typeof(IdGraphType));
            // TODO: Field(x => x.ModifiedByUser, type: typeof(UserType));
        }
Exemplo n.º 18
0
        public List <ControlBaseDTO> Get()
        {
            var repository = new DocumentTypeRepository();

            return(repository.GetDocumentTypes());
        }
Exemplo n.º 19
0
 public DocumentTypeServices()
 {
     _documentTypeAccountRepository = new DocumentTypeRepository();
 }