zhengyuxuan
2025-04-01 aff6340db92f4801184db829eccfed93ff6fedb3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using LifePayment.Application.Contracts;
using LifePayment.Domain.Common;
using LifePayment.Domain.Models;
using LifePayment.Domain.Shared;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;
 
namespace LifePayment.Application
{
    public class CommonService : ApplicationService, ICommonService
    {
        private readonly IRepository<OnlineService, Guid> _onlineServiceRepository;
 
        public CommonService(
               IRepository<OnlineService, Guid> onlineServiceRepository)
        {
            _onlineServiceRepository = onlineServiceRepository;
        }
 
        public async Task<string> GetOnlineService()
        {
            var query = await _onlineServiceRepository.FirstOrDefaultAsync();
           
            return query.Link;
        }
 
        public async Task UpdateOnlineService(OnlineServiceInput input)
        {
            var area = await _onlineServiceRepository.FirstOrDefaultAsync();
            if (area != null)
            {
                area.Link = input.Link;
            }
            else
            {
                OnlineService onlineService = new OnlineService()
                {
                    Id = Guid.NewGuid(),
                    Link = input.Link
                };
                await _onlineServiceRepository.InsertAsync(onlineService);
            }
        }
    }
}