Beispiel #1
0
 public async Task <IActionResult> GetItemDetailById(
     [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "SubItemDetailGetOne/{id}")] HttpRequest req,
     ILogger log, int id)
 {
     log.LogInformation($"Got sub item detail by id {id}");
     return(new OkObjectResult(await repo.GetOneAsync <SubItemDetail, SubItemDetailModel>(id)));
 }
Beispiel #2
0
        public async Task <IActionResult> PartiallyUpdate(int id, [FromBody] JsonPatchDocument <SubItemDetailModel> model)
        {
            if (id == 0)
            {
                return(BadRequest());
            }

            var record = await repo.GetOneAsync <SubItemDetail, SubItemDetailModel>(id);

            if (record.Value.Id == 0)
            {
                return(NotFound());
            }

            model.ApplyTo(record.Value, ModelState);
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var maybe = await repo.UpdateAsync <SubItemDetail, SubItemDetailModel>(record.Value);

            if (maybe.IsSuccess)
            {
                return(NoContent());
            }
            return(BadRequest(maybe.Error));
        }