Esempio n. 1
0
        public async Task AddDistinctionAsync(DistinctionDTO distinctionDTO, ClaimsPrincipal user)
        {
            CheckIfAdmin(user);
            var distinction = _mapper.Map <DistinctionDTO, Distinction>(distinctionDTO);
            await _repoWrapper.Distinction.CreateAsync(distinction);

            await _repoWrapper.SaveAsync();
        }
Esempio n. 2
0
        public async Task AddDistinctionAsync(DistinctionDTO distinctionDTO, User user)
        {
            await CheckIfAdminAsync(user);

            var distinction = _mapper.Map <DistinctionDTO, Distinction>(distinctionDTO);
            await _repoWrapper.Distinction.CreateAsync(distinction);

            await _repoWrapper.SaveAsync();
        }
Esempio n. 3
0
        public async Task ChangeDistinctionAsync(DistinctionDTO distinctionDTO, ClaimsPrincipal user)
        {
            CheckIfAdmin(user);
            var distinction = await _repoWrapper.Distinction.GetFirstAsync(x => x.Id == distinctionDTO.Id);

            distinction.Name = distinctionDTO.Name;
            _repoWrapper.Distinction.Update(distinction);
            await _repoWrapper.SaveAsync();
        }
Esempio n. 4
0
        public async Task AddDistinctionAsync(DistinctionDTO distinctionDTO, ClaimsPrincipal user)
        {
            if (!user.IsInRole("Admin"))
            {
                throw new UnauthorizedAccessException();
            }
            var distinction = _mapper.Map <DistinctionDTO, Distinction>(distinctionDTO);
            await _repoWrapper.Distinction.CreateAsync(distinction);

            await _repoWrapper.SaveAsync();
        }
Esempio n. 5
0
        public async Task ChangeDistinctionAsync(DistinctionDTO distinctionDTO, ClaimsPrincipal user)
        {
            if (!user.IsInRole("Admin"))
            {
                throw new UnauthorizedAccessException();
            }
            var distinction = await _repoWrapper.Distinction.GetFirstAsync(x => x.Id == distinctionDTO.Id);

            distinction.Name = distinctionDTO.Name;
            _repoWrapper.Distinction.Update(distinction);
            await _repoWrapper.SaveAsync();
        }