public async Task<RedirectToActionResult> CreateNewExercise([FromForm] ExerciseOfmForPost exerciseOfmForPost) { var postResult = await _exerciseViewModelRepository.Create(exerciseOfmForPost); if (postResult.HttpStatusCode == HttpStatusCode.Unauthorized || postResult.HttpStatusCode == HttpStatusCode.Forbidden) { return RedirectToAction("AccessDenied", "Authorization"); } //if ((int)postResult.HttpStatusCode != 201) //{ // // Todo: Do something when posting failed //} return RedirectToAction("Overview"); }
public async Task <IActionResult> Post([FromBody] ExerciseOfmForPost ofmForPost) { var stringGuid = User.Claims.FirstOrDefault(c => c.Type == "sub")?.Value; if (String.IsNullOrWhiteSpace(stringGuid)) { return(Unauthorized()); } var ownerGuid = new Guid(stringGuid); if (!_controllerGuardClause.ValidatePost(ofmForPost, out ObjectResult objectResult)) { return(objectResult); } var ofmForGet = await _asyncOfmRepository.Post(ofmForPost, ownerGuid); var result = CreatedAtRoute(routeName: "GetExerciseById", routeValues: new { id = ofmForGet.Id }, value: ofmForGet); return(result); }