public async Task <bool?> EditParagliderModel(int paragliderId, ParagliderModelPatchDto pParagliderPatch)
        {
            var toModifyAsParaglider = _paraContext.ParagliderModels.Select(p => p).Where(pId => pId.ID == paragliderId).FirstOrDefault();

            toModifyAsParaglider.MaxWeightPilot = (int)pParagliderPatch.MaxWeightPilot;
            toModifyAsParaglider.MinWeightPilot = (int)pParagliderPatch.MinWeightPilot;

            return(await _paraContext.SaveChangesAsync() > 0);
        }
Beispiel #2
0
        public async Task <IActionResult> EditPost(ParagliderModelDto pParaModelToModify)
        {
            ParagliderModelPatchDto paragliderModelAsPatchDto = new ParagliderModelPatchDto
            {
                MaxWeightPilot = pParaModelToModify.MaxWeightPilot,
                MinWeightPilot = pParaModelToModify.MinWeightPilot
            };

            using (var httpClient = new HttpClient())
            {
                var content  = new StringContent(JsonConvert.SerializeObject(paragliderModelAsPatchDto), Encoding.UTF8, "application/json-patch+json");
                var response = await httpClient.PatchAsync($"http://localhost:50106/api/v1/paragliderModels/{pParaModelToModify.ID}", content);
            }
            return(RedirectToAction("Index"));
        }