Beispiel #1
0
        public async Task <IActionResult> Create([FromBody] Applicant Applicant)
        {
            _logger.LogDebug("Starting save");

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

            // var deficiencies = new List<Deficiency>();
            // deficiencies.Add(new Deficiency {
            //     CategoryDeficiency = new CategoryDeficiency { Category = new Category { Name = "Test Category 1", Area = new Area { Name = "Test Area 1" } } }
            // });

            _applicantRepository.Add(
                new Applicant {
                Id       = new Random().Next(),
                LastName = Applicant.LastName,
                //Deficiencies = deficiencies
            });

            await _applicantRepository.SaveChangesAsync();

            _logger.LogDebug("Finished save");

            return(CreatedAtAction(nameof(Get), new { id = Applicant.LastName }, Applicant));
        }