public async Task <IActionResult> SetSystemSettings([FromBody] AgentAccommodationBookingSettingsInfo settings, [FromRoute] int agentId, [FromRoute] int agencyId) { var(_, isFailure, error) = await _systemSettingsManagementService.SetAvailabilitySearchSettings(agentId, agencyId, settings); if (isFailure) { return(BadRequest(ProblemDetailsBuilder.Build(error))); } return(Ok()); }
public AgentSystemSettingsCreateOrEditEventData(int agentId, int agencyId, AgentAccommodationBookingSettingsInfo newSettings) { AgentId = agentId; AgencyId = agencyId; NewSettings = newSettings; }
public static AgentAccommodationBookingSettings ToAgentAccommodationBookingSettings(this AgentAccommodationBookingSettingsInfo settings) => new ()
public Task <Result> SetAvailabilitySearchSettings(int agentId, int agencyId, AgentAccommodationBookingSettingsInfo settings) { return(CheckRelationExists(agentId, agencyId) .BindWithTransaction(_context, () => Result.Success() .Map(() => GetOrDefault(agentId, agencyId)) .Tap(Update) .Bind(WriteAuditLog))); Task Update(AgentSystemSettings existingSettings) { if (existingSettings is null) { var newSettings = new AgentSystemSettings { AgencyId = agencyId, AgentId = agentId, AccommodationBookingSettings = settings.ToAgentAccommodationBookingSettings() }; _context.Add(newSettings); } else { existingSettings.AccommodationBookingSettings = settings.ToAgentAccommodationBookingSettings(); _context.Update(existingSettings); } return(_context.SaveChangesAsync()); } Task <Result> WriteAuditLog(AgentSystemSettings _) => _managementAuditService.Write(ManagementEventType.AgentSystemSettingsCreateOrEdit, new AgentSystemSettingsCreateOrEditEventData(agentId, agencyId, settings)); }