コード例 #1
0
        public async Task <int> AddNewTagAsync(string tagName, AmoAccount account)
        {
            using var scope = scopeFactory.CreateScope();
            var db  = scope.ServiceProvider.GetRequiredService <ITagRepo>();
            var tag = await db.GetTagByName(tagName, account.id);

            if (tag is not null)
            {
                return(tag.Id);
            }
            try
            {
                var leadRepo = account.GetRepo <Lead>();
                var newTag   = leadRepo.AddTag(tagName).FirstOrDefault();
                await db.AddTag(new DBRepository.Tag()
                {
                    Id    = newTag.id,
                    Name  = newTag.name,
                    AmoId = account.id
                });

                return(newTag.id);
            }
            catch (Exception e) { throw new InvalidOperationException($"Unable to add tag {tagName}: {e.Message}"); }
        }
コード例 #2
0
        public async Task <DBRepository.Tag> GetTagAsync(int tagId, AmoAccount account)
        {
            using var scope = scopeFactory.CreateScope();
            var db = scope.ServiceProvider.GetRequiredService <ITagRepo>();

            return(await db.GetTagById(tagId, account.id));
        }
コード例 #3
0
        public async Task <int> AddNewCFAsync(string fieldName, AmoAccount acc)
        {
            using var scope = scopeFactory.CreateScope();
            var db = scope.ServiceProvider.GetRequiredService <ICFRepo>();
            var cf = await db.GetCFByNameAsync(fieldName, acc.id);

            if (cf is not null)
            {
                return(cf.Id);
            }
            try
            {
                var leadRepo = acc.GetRepo <Lead>();
                var newCF    = leadRepo.AddField(fieldName).FirstOrDefault();
                await db.AddCFAsync(new CF()
                {
                    Id    = newCF.id,
                    Name  = newCF.name,
                    AmoId = acc.id
                });

                return(newCF.id);
            }
            catch (Exception e) { throw new InvalidOperationException($"Unable to add custom field {fieldName}: {e.Message}"); }
        }
コード例 #4
0
        public async Task <CF> GetCFAsync(int fieldId, AmoAccount acc)
        {
            using var scope = scopeFactory.CreateScope();
            var db = scope.ServiceProvider.GetRequiredService <ICFRepo>();

            return(await db.GetCFByIdAsync(fieldId, acc.id));
        }
コード例 #5
0
        public async Task <string> GetTagNameAsync(int tagId, AmoAccount account)
        {
            using var scope = scopeFactory.CreateScope();
            var db  = scope.ServiceProvider.GetRequiredService <ITagRepo>();
            var tag = await db.GetTagById(tagId, account.id);

            return(tag.Name);
        }
コード例 #6
0
        public async Task <List <CustomField> > GetCFListAsync(AmoAccount acc)
        {
            using var scope = scopeFactory.CreateScope();
            var db   = scope.ServiceProvider.GetRequiredService <ICFRepo>();
            var list = await db.GetAllCFsAsync();

            return(list.Select(x => new CustomField()
            {
                id = x.Id, name = x.Name
            }).ToList());
        }
コード例 #7
0
        public async Task <int> GetCFIdAsync(string fieldName, AmoAccount acc)
        {
            using var scope = scopeFactory.CreateScope();
            var db = scope.ServiceProvider.GetRequiredService <ICFRepo>();
            var cf = await db.GetCFByNameAsync(fieldName, acc.id);

            if (cf is not null)
            {
                return(cf.Id);
            }
            return(await AddNewCFAsync(fieldName, acc));
        }
コード例 #8
0
        public async Task <int> GetTagIdAsync(string tagName, AmoAccount account)
        {
            using var scope = scopeFactory.CreateScope();
            var db  = scope.ServiceProvider.GetRequiredService <ITagRepo>();
            var tag = await db.GetTagByName(tagName, account.id);

            if (tag is not null)
            {
                return(tag.Id);
            }
            return(await AddNewTagAsync(tagName, account));
        }
コード例 #9
0
        public async Task <List <AmoRepo.Tag> > GetTagListAsync(AmoAccount account)
        {
            List <AmoRepo.Tag> result = new();

            using var scope = scopeFactory.CreateScope();
            var db   = scope.ServiceProvider.GetRequiredService <ITagRepo>();
            var tags = await db.GetAllTags();

            return(tags.Select(x => new AmoRepo.Tag()
            {
                id = x.Id, name = x.Name
            }).ToList());
        }
コード例 #10
0
ファイル: AmoAccountExtensions.cs プロジェクト: u705708/MZPO
 public static async Task <int> AddNewCFAsync(this AmoAccount acc, string cfName)
 {
     return(await acc.dataProvider.AddNewCFAsync(cfName, acc));
 }
コード例 #11
0
ファイル: AmoAccountExtensions.cs プロジェクト: u705708/MZPO
        public static async Task <Dictionary <string, int> > GetCFDictionaryAsync(this AmoAccount acc)
        {
            var list = await acc.dataProvider.GetCFListAsync(acc);

            return(list.ToDictionary(x => x.name, x => x.id));
        }
コード例 #12
0
ファイル: AmoAccountExtensions.cs プロジェクト: u705708/MZPO
 public static async Task <int> GetCFIdAsync(this AmoAccount acc, string fieldName)
 {
     return(await acc.dataProvider.GetCFIdAsync(fieldName, acc));
 }
コード例 #13
0
ファイル: AmoAccountExtensions.cs プロジェクト: u705708/MZPO
 public static async Task <int> GetTagIdAsync(this AmoAccount acc, string tagName)
 {
     return(await acc.dataProvider.GetTagIdAsync(tagName, acc));
 }
コード例 #14
0
ファイル: AmoAccountExtensions.cs プロジェクト: u705708/MZPO
 public static async Task <List <City> > GetCityListAsync(this AmoAccount acc)
 {
     return(await acc.dataProvider.GetCityListAsync());
 }
コード例 #15
0
ファイル: AmoAccountExtensions.cs プロジェクト: u705708/MZPO
 public static async Task AddNewCityAsync(this AmoAccount acc, string engCity, string rusCity)
 {
     await acc.dataProvider.AddNewCityAsync(engCity, rusCity);
 }
コード例 #16
0
ファイル: AmoAccountExtensions.cs プロジェクト: u705708/MZPO
 public static async Task <string> GetCityAsync(this AmoAccount acc, string input)
 {
     return(await acc.dataProvider.GetRusCityNameAsync(input));
 }