public IActionResult CreateEmployee(EmployeeCreateCommand command)
        {
            //var fname = Request.Form["fName"];
            employeeCommandFacade.CreateEmployee(command);

            return(RedirectToAction("SignUp"));
        }
        public void Constructor_Assigns_Properties_From_Parameters(Guid newId, EmployeeNew employee)
        {
            var sut = new EmployeeCreateCommand(newId, employee);

            sut.NewId.Should().Be(newId);
            sut.Employee.Should().Be(employee);
        }
Exemple #3
0
        public void Execute_EmployeeCreate_NewReadModelCreated()
        {
            // Arrange
            var expectedNumberOfEmployee = 1;
            var name    = "Jet Lee";
            var command = new EmployeeCreateCommand(name, "Scrum Master", 8, 180);

            var queryServiceEmployee = container.Resolve <IRepository <EmployeeReadModel> >();
            var bus = container.Resolve <IBus>();

            // Act
            bus.Dispatch(command);

            // Assert
            Assert.AreEqual(expectedNumberOfEmployee, queryServiceEmployee.FindList(x => x.Name == name).Count());
            Assert.AreEqual(name, queryServiceEmployee.All().Single().Name);
        }
Exemple #4
0
        public void Execute_EmployeeCreate_NewEmployeeCreated()
        {
            // Arrange
            var expectedNumberOfEmployee = 1;
            var name    = "Chuck Norris";
            var command = new EmployeeCreateCommand(name, "Architecture", 10, 200);

            var bus = container.Resolve <IBus>();
            var queryServiceEmployee = container.Resolve <IRepository <Employee> >();

            // Act
            bus.Dispatch(command);

            // Assert
            Assert.AreEqual(
                expectedNumberOfEmployee,
                queryServiceEmployee.FindList(x => x.Name == name).Count());

            Assert.AreEqual(name, queryServiceEmployee.All().Single().Name);
        }
            public void should_handle_create_employee_command()
            {
                // Arrange
                var inputCommand =
                    new EmployeeCreateCommand("joe", "bedford", "*****@*****.**");

                EmployeeRepositoryMock
                .Setup(i => i.CreateAsync(It.IsAny <Employee>()))
                .Returns(Task.CompletedTask);

                UnitOfWorkMock
                .Setup(i => i.CommitAsync(default(CancellationToken)))
                .ReturnsAsync(1);

                // Act
                var result = EmployeeCreateCommandHandlerUnderTest.Handle(inputCommand, default(CancellationToken)).Result;

                // Assert
                Assert.NotEqual(Guid.Empty, result.Id);
            }
        public override Task <ActionResult <Employee> > HandleAsync([FromBody] EmployeeCreateRequest request, CancellationToken token)
        {
            var command = new EmployeeCreateCommand(
                generator.Generate(),
                new EmployeeNew
            {
                Department          = request.Department,
                Email               = request.Email,
                EmploymentStartedOn = request.EmploymentStartedOn,
                FirstName           = request.FirstName,
                LastName            = request.LastName,
                Phone               = request.Phone,
                Status              = request.Status,
                Title               = request.Title
            });

            return(dispatcher
                   .Dispatch(command)
                   .Match <Employee, ActionResult <Employee> >(
                       employee => employee,
                       ex => new APIErrorResult(ex.Message)));
        }
 public void CreateEmployee(EmployeeCreateCommand command)
 {
     CommandBus.Dispatch(command);
 }
Exemple #8
0
        public async Task <IActionResult> Post(EmployeeCreateCommand command)
        {
            string response = await _mediator.Send(command);

            return(Ok(response));
        }
 public void CreateEmployee(EmployeeCreateCommand command)
 {
     commandFacade.CreateEmployee(command);
 }