예제 #1
0
        public async Task <Result> SetDisplayedPaymentOptions(int agencyId, DisplayedPaymentOptionsSettings 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,
                        DisplayedPaymentOptions = settings
                    };
                    _context.AgencySystemSettings.Add(newSettings);
                }
                else
                {
                    existingSettings.DisplayedPaymentOptions = settings;
                    _context.Update(existingSettings);
                }

                await _context.SaveChangesAsync();

                return(Result.Success());
            }
        }
예제 #2
0
 public async Task <IActionResult> SetDisplayedPaymentOptions([FromBody] DisplayedPaymentOptionsSettings settings, [FromRoute] int agencyId)
 => NoContentOrBadRequest(await _systemSettingsManagementService.SetDisplayedPaymentOptions(agencyId, settings));