Exemplo n.º 1
0
        public ActionResult UpdateCurriculum(CurriculumModel curriculum)
        {
            if (curriculum == null)
            {
                return(Ok());
            }

            var validator  = new CurriculumValidator();
            var validation = validator.Validate(curriculum);

            if (_readService.Get(curriculum.Rank, curriculum.RankType) == null)
            {
                validation.Errors.Add(new ValidationFailure("Invalid_Curriculum_Data", "Forkert data for gradueringen."));
            }

            if (!validation.IsValid)
            {
                return(BadRequest(validation));
            }

            var result = _writeService.Update(curriculum);

            return(Ok(result));
        }
Exemplo n.º 2
0
        public ActionResult CreateNewCurriculum(CurriculumModel curriculum)
        {
            if (curriculum == null)
            {
                return(Ok());
            }

            var validator  = new CurriculumValidator();
            var validation = validator.Validate(curriculum);

            if (_readService.Get(curriculum.Rank, curriculum.RankType) != null)
            {
                validation.Errors.Add(new ValidationFailure("Dual_Rank_&_RankTypeName", CreateDuplicateRankMessage(curriculum), new { curriculum.Rank, curriculum.RankType }));
            }

            if (!validation.IsValid)
            {
                return(StatusCode(422, validation));
            }

            var result = _writeService.Create(curriculum);

            return(CreatedAtAction(nameof(GetByRankTypeId), result));
        }