public async Task <IActionResult> Post([FromRoute] Guid clientId, [FromBody] Policy policy)
        {
            if (await _clientRepository.GetClient(clientId) == null)
            {
                return(NotFound());
            }

            var addedPolicy = await _policyRepository.AddPolicy(clientId, policy);

            return(CreatedAtAction(nameof(Get), new { clientId, id = addedPolicy.Id }, addedPolicy));
        }
Example #2
0
        public async Task <bool> AddPolicy(Policy policy, File file)
        {
            var id = await _policyRepository.AddPolicy(policy);

            if (id > 0)
            {
                await _s3Repository.StoreFile(_crypRepository.SignData(id.ToString()), file);

                return(true);
            }
            return(false);
        }
        public async Task <ActionResult <Policy> > AddPolicy([FromBody] Policy newPolicy)
        {
            try
            {
                var result = await _policyRepository.AddPolicy(newPolicy);

                if (result != null)
                {
                    return(Ok(result));
                }

                _logger.Log(LogLevel.Warning, $"Couldn't add policy {newPolicy.PolicyName}");
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }
            catch (Exception ex)
            {
                _logger.Log(LogLevel.Error, $"Error while call AddPolicy - {ex}");
                return(BadRequest(ex.Message));
            }
        }
 public Policy AddPolicy(Policy policy)
 {
     return(_policyRepo.AddPolicy(policy));
 }
        public void AddPolicy([FromBody] PolicyEntity policy)
        {
            var policiTest = new PolicyType();

            _policyRepository.AddPolicy(policy);
        }
Example #6
0
 public IActionResult Create(Policy policy)
 {
     policyRepo.AddPolicy(policy);
     return(RedirectToAction("Index"));
 }