示例#1
0
        public async Task <IActionResult> CreateEmployeeInfo([FromBody] CreateEmployeeInfo writeModel)
        {
            try
            {
                await _employeeCmdHdlr.Handle(writeModel);

                GetEmployee queryParams = new GetEmployee {
                    EmployeeID = writeModel.Id
                };

                IActionResult retValue = await _employeeQryReqHdler.Handle <GetEmployee>(queryParams, HttpContext, Response);

                return(CreatedAtAction(nameof(Details), new { employeeId = writeModel.Id }, (retValue as OkObjectResult).Value));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(BadRequest(ex.Message));
            }
        }
        public async Task <IActionResult> CreateEmployeeContactInfo([FromBody] CreateEmployeeContactInfo writeModel)
        {
            try
            {
                await _employeeCmdHdlr.Handle(writeModel);

                GetEmployeeContact queryParams = new GetEmployeeContact {
                    PersonID = writeModel.PersonId
                };

                IActionResult retValue = await _employeeQryReqHdler.Handle <GetEmployeeContact>(queryParams, HttpContext, Response);

                return(CreatedAtAction(nameof(GetEmployeeContact), new { personId = writeModel.PersonId }, (retValue as OkObjectResult).Value));
            }
            catch (Exception ex)
            {
                _logger.LogError($"An exception has been thrown: {ex}");
                return(BadRequest(ex.Message));
            }
        }