public async Task <IActionResult> Post(string organizationId, [FromBody] CreateIPFencingViewModel request)
        {
            try
            {
                var ipCheck = _iPFencingOptions.IPFencingCheck;
                if (ipCheck.Equals("Disabled"))
                {
                    throw new UnauthorizedOperationException("IPFencing rule could not be added because IPFencingCheck is disabled", EntityOperationType.Add);
                }

                IPFencing iPFencing = request.Map(request);
                iPFencing.OrganizationId = Guid.Parse(organizationId);

                return(await base.PostEntity(iPFencing));
            }
            catch (Exception ex)
            {
                return(ex.GetActionResult());
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> Post(string organizationId, [FromBody] CreateIPFencingViewModel request)
        {
            try
            {
                var ipCheck = iPFencingOptions.IPFencingCheck;
                if (ipCheck.Equals("Disabled"))
                {
                    ModelState.AddModelError("Post", "IPFencing rule could not be added because IPFencingCheck is disabled");
                    return(NotFound(ModelState));
                }

                IPFencing iPFencing = request.Map(request);
                iPFencing.OrganizationId = Guid.Parse(organizationId);

                return(await base.PostEntity(iPFencing));
            }
            catch (Exception ex)
            {
                return(ex.GetActionResult());
            }
        }