Beispiel #1
0
        private static void SeedTemplate(ApplicationDbContext context)
        {
            var service = new DocumentsTemplateService(context);

            if (context.DocumentTemplates.Any())
            {
                return;
            }

            var fileData = File.ReadAllBytes(Environment.CurrentDirectory + @"\Application\Resources\cerere_pentru_cazare_2014-2015.pdf");

            service.AddTemplate(DocumentTemplates.NUME, fileData);
            context.SaveChanges();
        }
Beispiel #2
0
        public UnitOfWork(ApplicationDbContext dbContext)
        {
            this.dbContext = dbContext;

            DocumentsService             = new DocumentsService(dbContext);
            DocumentsStatesService       = new DocumentsStatesService(dbContext);
            DocumentsTemplateItemService = new DocumentsTemplateItemService(dbContext);
            DocumentsTemplateService     = new DocumentsTemplateService(dbContext);
            DocumentTaskTemplatesService = new DocumentTaskTemplatesService(dbContext);
            DocumentTasksService         = new DocumentTasksService(dbContext);
            LogsService       = new LogsService(dbContext);
            RolesService      = new RolesService(dbContext);
            TagsService       = new TagsService(dbContext);
            UsersService      = new UsersService(dbContext);
            UserGroupsService = new UserGroupsService(dbContext);
        }
        public async Task Can_Get_All_Templates()
        {
            var dbContextOptions = CreateNewContextOptions();

            using (var context = new ApplicationDbContext(dbContextOptions))
            {
                context.DocumentTemplates.AddRange(new DocumentTemplate(), new DocumentTemplate());
                await context.SaveChangesAsync();
            }

            using (var context = new ApplicationDbContext(dbContextOptions))
            {
                var service = new DocumentsTemplateService(context);
                var result  = await service.GetAllTemplates();

                Assert.Equal(2, result.Count);
            }
        }
        public async Task Can_Get_Template_By_Id()
        {
            var template         = new DocumentTemplate();
            var dbContextOptions = CreateNewContextOptions();

            using (var context = new ApplicationDbContext(dbContextOptions))
            {
                context.DocumentTemplates.Add(template);
                await context.SaveChangesAsync();
            }

            using (var context = new ApplicationDbContext(dbContextOptions))
            {
                var service = new DocumentsTemplateService(context);
                var result  = await service.GetTemplateById(template.IdDocumentTemplate);

                Assert.NotNull(result);
            }
        }