aboutsummaryrefslogtreecommitdiff
path: root/Source/ExcelDNA/Functions.cs
blob: a282e3e3454164128ff283c76240624c1114ac74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
using AngleSharp.Dom;
using ExcelDna.Integration;
using System.Net.Http;
using System.Threading.Tasks;

namespace Rehau.Sku.Assist
{
    public class Functions
    {
        [ExcelFunction]
        public static async Task<string> RAUNAME(string request)
        {
            Task<string> contentTask = Task.Run(() => SkuAssist.GetContent(request));
            Task<IDocument> documentTask = await contentTask.ContinueWith(content => SkuAssist.GetDocument(content));
            IProduct product = await documentTask.ContinueWith(doc => SkuAssist.GetProductFromDocument(doc.Result));
            return product != null ? product.ToString() : "Не найдено";
        }
    }
}