public IActionResult Update([FromBody] TrainingWeekWithScenario trainingWeekWithScenario) { try { if (trainingWeekWithScenario == null || trainingWeekWithScenario.TrainingWeek == null || trainingWeekWithScenario.TrainingWeekScenario == null) { return(BadRequest()); } var trainingWeek = trainingWeekWithScenario.TrainingWeek; var trainingWeekScenario = trainingWeekWithScenario.TrainingWeekScenario; if (trainingWeek.UserId != SessionUserId) { return(BadRequest()); } var result = _trainingWeeksService.UpdateTrainingWeek(trainingWeek, trainingWeekScenario); return(new OkObjectResult(result)); } catch (Exception exception) { return(BadRequest(new WebApiException("Error", exception))); } }
public static async Task <TrainingWeek> UpdateTrainingWeekAsync(TrainingWeek trainingWeek, TrainingWeekScenario trainingWeekScenario) { var trainingWeekWithScenario = new TrainingWeekWithScenario() { TrainingWeek = trainingWeek, TrainingWeekScenario = trainingWeekScenario }; return(await HttpConnector.Instance.PostAsync <TrainingWeekWithScenario, TrainingWeek> ("Api/TrainingWeeks/Update", trainingWeekWithScenario)); }