public async Task UpdatePatrol(Amphibian.Patrol.Api.Models.Patrol patrol) { //TODO: hack job, move this to a service if (!string.IsNullOrEmpty(patrol.TimeZone)) { patrol.TimeZone = TZConvert.GetTimeZoneInfo(patrol.TimeZone).Id; } await _connection.UpdateAsync(patrol) .ConfigureAwait(false); }
public void SetUp() { _patrolRepository = new PatrolRepository(_connection); _user = new User() { Email = "*****@*****.**", PasswordHash = new byte[32], PasswordSalt = new byte[32], PasswordHashIterations = 5, FirstName = "Test", LastName = "Test" }; _user.Id = (int)_connection.Insert(_user); _patrol = new Amphibian.Patrol.Api.Models.Patrol() { Name = "Test", TimeZone = "Eastern Standard Time" }; }
public async Task <IActionResult> Update(Amphibian.Patrol.Api.Models.Patrol patrol) { if (User.RoleInPatrol(patrol.Id).CanmaintainPatrol()) { await _patrolRepository.UpdatePatrol(patrol); //TODO: we don't need this once the UI uses the JWT var patrols = await _patrolRepository.GetPatrolsForUser(User.UserId()); //refresh the users jwt to match the above change Response.SendNewToken(await _authenticationService.IssueJwtToUser(User.UserId(), User.TokenGuid())); var patrolUsers = (await _patrolRepository.GetUsersForPatrol(patrol.Id)).ToList(); patrolUsers = patrolUsers.Where(x => x.Id != User.UserId()).ToList(); await _tokenRepository.SupersedeActiveTokensForUsers(patrolUsers.Select(x => x.Id).ToList(), _systemClock.UtcNow.UtcDateTime); return(Ok(patrols)); } else { return(Forbid()); } }