Ejemplo n.º 1
0
        public IActionResult PostDetail(string id, [FromBody] StudyPlanDetailPostRequestDto dto)
        {
            if (!Guid.TryParse(id, out var studyPlanId))
            {
                return(BadRequest("Unable to parse the ID of the StudyPlan."));
            }

            var newObject = _studyPlanService.AddNewDetail(studyPlanId, dto.Name, dto.SubjectId);

            return(Redirect("/api/study-plans/" + id + "/details/" + newObject.Id));
        }
Ejemplo n.º 2
0
        public IActionResult PutDetail(string idStudyPlan, string id, [FromBody] StudyPlanDetailPostRequestDto dto)
        {
            if (!Guid.TryParse(idStudyPlan, out var studyPlanId))
            {
                return(BadRequest("Unable to parse the ID of the StudyPlan."));
            }

            if (!Guid.TryParse(id, out var studyPlanDetailId))
            {
                return(BadRequest("Unable to parse the ID of the StudyPlanDetail."));
            }

            var objectUpdated = _studyPlanService.UpdateDetail(studyPlanId, studyPlanDetailId, dto.Name, dto.SubjectId);

            if (objectUpdated == null)
            {
                return(NotFound());
            }

            return(Redirect("/api/study-plans/" + studyPlanId + "/details/" + studyPlanDetailId));
        }