Ejemplo n.º 1
0
        public async Task <IActionResult> ExecuteAsync(int id, SaveSystemSettingGroup saveSystemSettingGroup, CancellationToken cancellationToken)
        {
            var systemSettingGroup = await _systemSettingGroupRepository.Get(id, cancellationToken);

            if (systemSettingGroup == null)
            {
                return(new NotFoundResult());
            }

            _saveSystemSettingGroupToSystemSettingGroupMapper.Map(saveSystemSettingGroup, systemSettingGroup);

            //var user = _httpContextAccessor.HttpContext.User;
            //if (user == null)
            //    return new NotFoundResult();

            //var claims = user.Claims.ToList();
            //if (claims.Count < 1)
            //    return new NotFoundResult();
            //// Lấy Id của người dùng
            //var userId = claims.FirstOrDefault(claimRecord => claimRecord.Type == "sub")?.Value;

            //systemSettingGroup.ModifiedBy = userId;

            systemSettingGroup = await _systemSettingGroupRepository.Update(systemSettingGroup, cancellationToken);

            var systemSettingGroupViewModel = _systemSettingGroupToSystemSettingGroupMapper.Map(systemSettingGroup);

            return(new OkObjectResult(systemSettingGroupViewModel));
        }
        public async Task <IActionResult> ExecuteAsync(int id, CancellationToken cancellationToken)
        {
            var systemSettingGroup = await _systemSettingGroupRepository.Get(id, cancellationToken);

            if (systemSettingGroup == null)
            {
                return(new NotFoundResult());
            }

            await _systemSettingGroupRepository.Delete(systemSettingGroup, cancellationToken);

            return(new NoContentResult());
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> ExecuteAsync(int id, CancellationToken cancellationToken)
        {
            var systemSettingGroup = await _systemSettingGroupRepository.Get(id, cancellationToken);

            if (systemSettingGroup == null)
            {
                return(new NotFoundResult());
            }

            var systemSettingGroupViewModel = _systemSettingGroupMapper.Map(systemSettingGroup);

            return(new OkObjectResult(systemSettingGroupViewModel));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> ExecuteAsync(SaveSystemSetting saveSystemSetting, CancellationToken cancellationToken)
        {
            if (await _systemSettingGroupRepository.Get(saveSystemSetting.GroupId, cancellationToken) == null)
            {
                return(new NotFoundResult());
            }

            var systemSetting = await _systemSettingRepository.GetByKey(saveSystemSetting.Key, cancellationToken);

            if (systemSetting != null)
            {
                return(new NotFoundResult());
            }
            systemSetting = _saveSystemSettingToSystemSettingMapper.Map(saveSystemSetting);

            //var user = _httpContextAccessor.HttpContext.User;
            //if (user == null)
            //    return new NotFoundResult();

            //var claims = user.Claims.ToList();
            //if (claims.Count < 1)
            //    return new NotFoundResult();
            //// Lấy Id của người dùng
            //var userId = claims.FirstOrDefault(claimRecord => claimRecord.Type == "sub")?.Value;

            //systemSetting.CreatedBy = userId;
            //systemSetting.ModifiedBy = userId;

            systemSetting = await _systemSettingRepository.Add(systemSetting, cancellationToken);

            var systemSettingViewModel = _systemSettingToSystemSettingMapper.Map(systemSetting);

            return(new CreatedAtRouteResult(
                       SystemSettingsControllerRoute.GetSystemSetting,
                       new { systemSettingViewModel.Key },
                       systemSettingViewModel));
        }