Exemplo n.º 1
0
        public async ValueTask <HttpResponseMessage> Claim_UpdateV1(string jwt, ClaimV1 model)
        {
            _http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", jwt);

            return(await _http.PutAsync("claim/v1",
                                        new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json")));
        }
Exemplo n.º 2
0
        public IActionResult UpdateV1([FromBody] ClaimV1 model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var claim = uow.Claims.GetAsNoTracking(QueryExpressionFactory.GetQueryExpression <tbl_Claim>()
                                                   .Where(x => x.Id == model.Id).ToLambda())
                        .SingleOrDefault();

            if (claim == null)
            {
                ModelState.AddModelError(MessageType.ClaimNotFound.ToString(), $"Claim:{model.Id}");
                return(NotFound(ModelState));
            }
            else if (claim.IsDeletable &&
                     claim.IsDeletable != model.IsDeletable)
            {
                ModelState.AddModelError(MessageType.ClaimImmutable.ToString(), $"Claim:{claim.Id}");
                return(BadRequest(ModelState));
            }

            var result = uow.Claims.Update(map.Map <tbl_Claim>(model));

            uow.Commit();

            return(Ok(map.Map <ClaimV1>(result)));
        }
Exemplo n.º 3
0
        public async ValueTask <ClaimV1> Claim_UpdateV1(ClaimV1 model)
        {
            var response = await Endpoints.Claim_UpdateV1(Grant.AccessToken.RawData, model);

            if (response.IsSuccessStatusCode)
            {
                return(await response.Content.ReadAsAsync <ClaimV1>().ConfigureAwait(false));
            }

            throw new HttpRequestException(response.RequestMessage.ToString(),
                                           new Exception(response.ToString()));
        }
Exemplo n.º 4
0
        public IActionResult CreateV1([FromBody] ClaimV1 model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (uow.Claims.Get(QueryExpressionFactory.GetQueryExpression <tbl_Claim>()
                               .Where(x => x.IssuerId == model.IssuerId && x.Type == model.Type).ToLambda())
                .Any())
            {
                ModelState.AddModelError(MessageType.ClaimAlreadyExists.ToString(), $"Issuer:{model.IssuerId} Claim:{model.Type}");
                return(BadRequest(ModelState));
            }

            var result = uow.Claims.Create(map.Map <tbl_Claim>(model));

            uow.Commit();

            return(Ok(map.Map <ClaimV1>(result)));
        }