示例#1
0
        public ActionResult <IEnumerable <UserResponseDto> > UpdateUsers([FromBody] IEnumerable <CreateUserDto> usersToBeUpdated)
        {
            List <UserResponseDto> response = new List <UserResponseDto>();

            foreach (var user in usersToBeUpdated)
            {
                response.Add(_creator.UpdateUser(user));
            }

            return(Ok(response));
        }
示例#2
0
        public ActionResult <IEnumerable <UserResponseDto> > UpdateUsers([FromBody] IEnumerable <CreateUserDto> usersToBeUpdated)
        {
            List <UserResponseDto> response = new List <UserResponseDto>();

            foreach (var user in usersToBeUpdated)
            {
                response.Add(_creator.UpdateUser(new CreateUserDto
                {
                    Id        = user.Id,
                    Email     = user.Email,
                    Name      = user.Name,
                    StartDate = user.StartDate
                }));
            }

            return(Ok(response));
        }
示例#3
0
        public void UserCreator_UpdateExistingUser_UserIsUpdated()
        {
            var context = new AlvTimeDbContextBuilder()
                          .WithUsers()
                          .CreateDbContext();

            var storage = new UserStorage(context);
            var creator = new UserCreator(storage, new AlvHoursCalculator());

            creator.UpdateUser(new CreateUserDto
            {
                Id        = 1,
                Email     = "*****@*****.**",
                Name      = "SomeoneElse",
                StartDate = DateTime.UtcNow
            });

            var user = context.User.FirstOrDefault(u => u.Id == 1);

            Assert.Equal("*****@*****.**", user.Email);
            Assert.Equal("SomeoneElse", user.Name);
        }