Example #1
0
        public async Task <Result> SetAvailabilitySearchSettings(int agencyId, AgencyAccommodationBookingSettings settings)
        {
            return(await CheckAgencyExists(agencyId)
                   .Bind(SetSettings));


            async Task <Result> SetSettings()
            {
                var existingSettings = await _context.AgencySystemSettings.SingleOrDefaultAsync(s => s.AgencyId == agencyId);

                if (existingSettings == default)
                {
                    var newSettings = new AgencySystemSettings
                    {
                        AgencyId = agencyId,
                        AccommodationBookingSettings = settings
                    };
                    _context.AgencySystemSettings.Add(newSettings);
                }
                else
                {
                    existingSettings.AccommodationBookingSettings = settings;
                    _context.Update(existingSettings);
                }

                await _context.SaveChangesAsync();

                return(Result.Success());
            }
        }
Example #2
0
 public static AgencyAccommodationBookingSettingsInfo ToAgencyAccommodationBookingSettingsInfo(this AgencyAccommodationBookingSettings settings)
 => new ()
Example #3
0
 public async Task <IActionResult> SetSystemSettings([FromBody] AgencyAccommodationBookingSettings settings, [FromRoute] int agencyId)
 => NoContentOrBadRequest(await _systemSettingsManagementService.SetAvailabilitySearchSettings(agencyId, settings));