public async Task CreateTest()
        {
            _context.Set <TProfilOption>().Where(a => a.Name == CREATE).SingleOrDefault().ShouldBe(null);

            var result = await _mediator.Send(new CreateProfilOptionCommand <TProfilOption> {
                Name = CREATE
            });

            result.ShouldBeOfType(typeof(Unit));

            _context.Set <TProfilOption>().Where(a => a.Name == CREATE).SingleOrDefault().ShouldNotBe(null);
        }
        private async Task <bool> IsLinked(int id)
        {
            var entity = await _context.Set <HeardOfUsFrom>()
                         .Include(hof => hof.Customers)
                         .SingleAsync(hof => hof.Id == id && hof.IsDelete == false);

            return(entity.Customers.Where(c => c.IsDelete == false).Count() > 0);
        }
예제 #3
0
        private async Task <bool> IsLinked(int id)
        {
            var entity = await _context.Set <ReferenceType>()
                         .Include(a => a.Customers)
                         .SingleAsync(a => a.Id == id && a.IsDelete == false);

            return(entity.Customers.Where(c => c.IsDelete == false).Count() > 0);
        }
예제 #4
0
        private async Task <bool> IsLinked(int id)
        {
            var entity = await _context.Set <VolunteeringType>()
                         .Include(a => a.Volunteerings)
                         .SingleAsync(a => a.Id == id);

            return(entity.Volunteerings.Where(v => v.IsDelete == false).Count() > 0);
        }
예제 #5
0
        private async Task <bool> IsLinked(int id)
        {
            var entity = await _context.Set <CitizenStatus>()
                         .Include(a => a.CustomerDescriptions)
                         .ThenInclude(cd => cd.Customer)
                         .SingleAsync(a => a.Id == id && a.IsDelete == false);

            return(entity.CustomerDescriptions.Where(c => c.Customer.IsDelete == false).Count() > 0);
        }
예제 #6
0
        private async Task <bool> IsLinked(int id)
        {
            var entity = await _context.Set <SkillToDevelop>()
                         .Include(a => a.CustomerSkillToDevelops)
                         .ThenInclude(cstd => cstd.Customer)
                         .SingleAsync(a => a.Id == id && a.IsDelete == false);

            return(entity.CustomerSkillToDevelops.Where(c => c.Customer.Customer.IsDelete == false).Count() > 0);
        }
예제 #7
0
        private async Task <bool> IsLinked(int id)
        {
            var entity = await _context.Set <SocialService>()
                         .Include(a => a.CustomerSocialServices)
                         .ThenInclude(css => css.Customer)
                         .SingleAsync(a => a.Id == id && a.IsDelete == false);

            return(entity.CustomerSocialServices.Where(c => c.Customer.Customer.IsDelete == false).Count() > 0);
        }
예제 #8
0
        private async Task <bool> IsLinked(int id)
        {
            var entity = await _context.Set <NoteType>()
                         .Include(a => a.Notes)
                         .ThenInclude(n => n.NoteType)
                         .SingleAsync(a => a.Id == id && a.IsDelete == false);

            return(entity.Notes.Where(d => d.IsDelete == false).Count() > 0);
        }
예제 #9
0
        public async Task <bool> IsLinked(int id)
        {
            var entity = await _context.Set <ChildrenAgeBracket>()
                         .Include(a => a.CustomerChildrenAgeBrackets)
                         .ThenInclude(ccab => ccab.Customer)
                         .ThenInclude(cd => cd.Customer)
                         .SingleAsync(a => a.Id == id && a.IsDelete == false);

            return(entity.CustomerChildrenAgeBrackets.Any(c => c.Customer.Customer.IsDelete == false));
        }
        public async Task <Unit> Handle(UpdateProfilOptionCommand <Availability> request, CancellationToken cancellationToken)
        {
            var availability = await _context.Set <Availability>().FindAsync(request.Id);

            availability.Name = request.Name;

            _context.Update(availability);
            await _context.SaveChangesAsync();

            return(Unit.Value);
        }
        public async Task Handle(ParentEspoirDbContext context, CancellationToken cancelationToken)
        {
            var option = await context.Set <TProfilOption>().FindAsync(Id);

            if (option != null)
            {
                option.IsDelete = true;

                await context.SaveChangesAsync(cancelationToken);
            }
        }
        public async Task <Unit> Handle(DeleteProfilOptionCommand <CitizenStatus> request, CancellationToken cancellationToken)
        {
            var citizenStatus = await _context.Set <CitizenStatus>().FindAsync(request.Id);

            citizenStatus.IsDelete = true;

            _context.Update(citizenStatus);
            await _context.SaveChangesAsync(cancellationToken);

            return(Unit.Value);
        }
        public CreateCitizenStatusCommandValidator(ParentEspoirDbContext context)
        {
            RuleFor(c => c.Name)
            .NotEmpty()
            .WithMessage("Le nom ne peut pas être vide");

            RuleFor(c => c.Name)
            .Must(n => string.IsNullOrWhiteSpace(n) == false &&
                  context.Set <CitizenStatus>().Where(vt => vt.IsDelete == false)
                  .Any(c => StringNormalizer.Normalize(c.Name) == StringNormalizer.Normalize(n)) == false)
            .WithMessage("Cette option existe déjà");
        }
예제 #14
0
        private async Task <List <IProfileOption> > GetProfilOption <T>() where T : class, IProfileOption
        {
            string key = $"{typeof(T).Name}List";

            if (!_cache.TryGetValue(key, out List <IProfileOption> profilOption))
            {
                profilOption = await _context.Set <T>().Where(po => po.IsDelete == false).ToListAsync <IProfileOption>();

                _cache.Set(key, profilOption, TimeSpan.FromHours(3));
            }

            return(profilOption);
        }
        public async Task <List <TProfilOption> > Handle(IMemoryCache memory, ParentEspoirDbContext context)
        {
            string optionName = $"{typeof(TProfilOption).Name}List";

            if (!memory.TryGetValue($"{optionName}", out List <TProfilOption> options))
            {
                options = await context.Set <TProfilOption>().Where(t => t.IsDelete == false).ToListAsync();

                memory.CreateEntry(optionName);
                memory.Set(optionName, options);
            }

            return(options);
        }