public async Task ShouldCreate_EmployeeInfo_UsingEmployeeController()
        {
            Guid id      = Guid.NewGuid();
            var  command = new CreateEmployeeInfo
            {
                Id            = id,
                SupervisorId  = id,
                LastName      = "Hello",
                FirstName     = "World",
                MiddleInitial = "Z",
                SSN           = "523789999",
                Telephone     = "214-654-9874",
                MaritalStatus = "S",
                Exemptions    = 2,
                PayRate       = 25.00M,
                StartDate     = new DateTime(2021, 8, 29),
                IsActive      = true
            };

            string      jsonEmployee = JsonConvert.SerializeObject(command);
            HttpContent content      = new StringContent(jsonEmployee, Encoding.UTF8, "application/vnd.btechnical-consulting.hateoas+json");
            var         response     = await _client.PostAsync($"{_serviceAddress}{_rootAddress}/createemployeeinfo", content);

            Assert.True(response.IsSuccessStatusCode);
        }
Exemple #2
0
        public async Task ShouldInsert_Employee_UsingCreateEmployeeInfoCommand()
        {
            Guid id      = Guid.NewGuid();
            var  command = new CreateEmployeeInfo
            {
                Id            = id,
                SupervisorId  = id,
                LastName      = "Hello",
                FirstName     = "World",
                MiddleInitial = "Z",
                SSN           = "523789999",
                Telephone     = "214-654-9874",
                MaritalStatus = "S",
                Exemptions    = 2,
                PayRate       = 25.00M,
                StartDate     = new DateTime(2021, 8, 29),
                IsActive      = true
            };

            await _employeeCmdHdlr.Handle(command);

            Employee result = await _dbContext.Employees.FindAsync(id);

            Assert.NotNull(result);
        }
Exemple #3
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));
            }
        }