public async Task <ActionResult> Update(int id, UpdateEmployeeContractCommand command)
        {
            if (id != command.Id)
            {
                return(BadRequest());
            }

            await Mediator.Send(command);

            return(NoContent());
        }
Ejemplo n.º 2
0
        public void ShouldRequireValidEmployeeContractId()
        {
            var command = new UpdateEmployeeContractCommand
            {
                Id           = 99999,
                Number       = "Number",
                ContractDate = DateTime.Now,
                ValidFrom    = DateTime.Now,
                ValidTo      = DateTime.Now
            };

            FluentActions.Invoking(() =>
                                   SendAsync(command)).Should().Throw <NotFoundException>();
        }
Ejemplo n.º 3
0
        public async Task ShouldUpdateEmployeeContract()
        {
            var userId = await RunAsDefaultUserAsync();

            var employeeId = await SendAsync(new CreateEmployeeCommand
            {
                FirstName = "TestFirstName",
                LastName  = "TestUpdateLastName",
                Email     = "*****@*****.**",
                Pesel     = "12345612"
            });

            var employeeContractId = await SendAsync(new CreateEmployeeContractCommand
            {
                EmployeeId   = employeeId,
                Number       = "BeforeNumber",
                ContractDate = DateTime.Now,
                ValidFrom    = DateTime.Now,
                ValidTo      = DateTime.Now
            });

            var command = new UpdateEmployeeContractCommand
            {
                Id           = employeeContractId,
                EmployeeId   = employeeId,
                Number       = "AfterNumber",
                ContractDate = DateTime.Now.AddDays(1),
                ValidFrom    = DateTime.Now.AddDays(-2),
                ValidTo      = DateTime.Now.AddDays(30)
            };

            await SendAsync(command);

            var contr = await FindAsync <EmployeeContract>(employeeContractId);

            contr.Should().NotBeNull();
            contr.Number.Should().Be(command.Number);
            contr.ContractDate.Should().Be(command.ContractDate);
            contr.ValidFrom.Should().Be(command.ValidFrom);
            contr.ValidTo.Should().Be(command.ValidTo);
            contr.LastModifiedBy.Should().NotBeNull();
            contr.LastModifiedBy.Should().Be(userId);
            contr.LastModified.Should().NotBeNull();
            contr.LastModified.Should().BeCloseTo(DateTime.Now, 1000);
        }