Exemplo n.º 1
0
        public async Task SetIsStaticPoolingAsync(OrganizationIsStaticPoolingDto dto)
        {
            if (dto == null)
            {
                throw new ArgumentNullException(nameof(dto));
            }

            await _organizationsRepository
            .SetIsStaticPoolingAsync(dto)
            .ConfigureAwait(false);
        }
Exemplo n.º 2
0
        public async Task <ActionResult> SetIsStaticPoolingAsync([FromBody] OrganizationIsStaticPoolingDto dto)
        {
            if (dto == null)
            {
                return(BadRequest());
            }

            await _organizationsService
            .SetIsStaticPoolingAsync(dto)
            .ConfigureAwait(false);

            if (!_organizationsService.ValidationDictionary.IsValid())
            {
                return(BadRequest(new { errors = _organizationsService.ValidationDictionary.GetErrorMessages() }));
            }

            return(NoContent());
        }
Exemplo n.º 3
0
        public async Task SetIsStaticPoolingAsync(OrganizationIsStaticPoolingDto dto)
        {
            if (dto == null)
            {
                throw new ArgumentNullException(nameof(dto));
            }

            await using var context = ContextFactory.CreateDataContext(null);
            var organizations = context.Organizations;
            var entity        = await organizations.AsNoTracking()
                                .FirstOrDefaultAsync(t => t.Id == dto.Id)
                                .ConfigureAwait(false);

            if (entity != null)
            {
                entity.IsStaticPooling      = dto.IsStaticPooling;
                entity.LastUpdatedOn        = DateTime.UtcNow;
                context.Entry(entity).State = EntityState.Modified;
                context.Organizations.Update(entity);

                await context.SaveChangesAsync()
                .ConfigureAwait(false);
            }
        }