Beispiel #1
0
        public async Task <IActionResult> Create([FromBody] EmployeeCreateRequest requestModel)
        {
            //if (!ModelState.IsValid)
            //{
            //    logger.Here().Warning("Created employee failed. Model is not valid");
            //    return BadRequest(ModelState);
            //}

            //map to entity
            Employee employee = EmployeeMapper.MapFromEmployeeCreateRequestToEmployee(requestModel);

            db.Employees.Add(employee);
            await db.SaveChangesAsync();

            logger.Here().Information("Created employee successfully");

            return(CreatedAtRoute("GetEmployeeById", new { id = employee.EmployeeId }, null));
        }