public async Task <bool> Put([FromBody] ChartEntity chart)
        {
            try
            {
                IChartRepository <ChartEntity> Respository = new ChartRepository <ChartEntity>(config);
                await Respository.UpdateItemAsync(chart.id, chart, "Chart");

                return(true);
            }
            catch
            {
                return(false);
            }
        }
        public JsonResult GetDataPoints([Bind("ACoeff,BCoeff,CCoeff,Step,LowerBorder,UpperBorder")] ChartEntity chart)
        {
            if (chart.LowerBorder >= chart.UpperBorder)
            {
                setError("LowerBorder", "LowerBorder must be less than upper one");
            }
            if (chart.Step <= 0)
            {
                setError("Step", "Step must be grower than Zero");
            }
            if (ModelState.IsValid)
            {
                List <Point> values = new List <Point>();
                int          yValue = 0;
                for (int i = chart.LowerBorder; i < chart.UpperBorder; i += chart.Step)
                {
                    yValue = chart.ACoeff * (i * i) + chart.BCoeff * i + chart.CCoeff;
                    values.Add(new Point(i, yValue));
                }
                return(Json(new { List = values, View = PartialView("_FunctionPartial") }));
            }

            return(Json(new { View = PartialView("_FunctionPartial") }));
        }
        public async Task <List <ChartEntity> > CreateItemAsync(ChartQuery chart, IConfiguration _config)
        {
            try
            {
                BlobStorageService objBlobService  = new BlobStorageService(_config);
                EmailService       objEmailService = new EmailService(_config);

                List <Attachment> attachments = new List <Attachment>();
                IChartRepository <ChartEntity> Respository = new ChartRepository <ChartEntity>(_config);


                ChartEntity newchart = new ChartEntity();
                newchart.id               = null;
                newchart.name             = chart.name;
                newchart.remarks          = chart.remarks;
                newchart.mailcontent      = chart.mailcontent;
                newchart.mailsubject      = chart.mailsubject;
                newchart.chartAttachments = chart.chartAttachments;
                newchart.userId           = chart.userId;
                newchart.email            = chart.email;
                newchart.phone            = chart.phone;
                newchart.username         = chart.username;
                newchart.isActive         = chart.isActive;
                newchart.createdBy        = chart.createdBy;
                newchart.createdDate      = chart.createdDate;
                newchart.modifiedBy       = chart.modifiedBy;
                newchart.modifiedDate     = chart.modifiedDate;

                // add base64 image to blob
                if (newchart.chartAttachments.Count() > 0)
                {
                    newchart.chartAttachments.ForEach(x =>
                    {
                        string[] strName = x.Name.Split('.');
                        //x.Path = newchart.userId + "/" + x.uId + "." + strName[strName.Length - 1];
                        //byte[] bytes = Encoding.ASCII.GetBytes(x.Base64String);

                        // upload to blob
                        //objBlobService.UploadFileToBlob(x.ContainerName, newchart.userId + "/" + x.uId + "." + strName[strName.Length - 1], Encoding.ASCII.GetBytes(x.Base64String), x.ContentType);

                        // add attachments
                        attachments.Add(new Attachment {
                            Content = x.Base64String, Type = x.ContentType, Filename = x.Name, Disposition = "attachment", ContentId = "chart"
                        });
                    });
                }


                var cht = await Respository.CreateItemAsync(newchart, "Chart");

                if (cht != null)
                {
                    // send Mail
                    var response = objEmailService.SendEmailAsync(newchart.mailsubject, newchart.email, "New Chart from Holistic Fitness", newchart.mailcontent, attachments);
                }


                List <ChartEntity> chtList = new List <ChartEntity>();
                return(chtList);
            }

            catch (Exception ex)
            {
                List <ChartEntity> chtList = null;
                return(chtList);
            }
        }
Beispiel #4
0
        public async Task <ActionResult> Generate(int Id)
        {
            Compiler.Common.Music.ChartType ChartType = (Compiler.Common.Music.ChartType)Id;

            IChartSongEntity     chartSongManager    = new ChartSongEntity(_currSettings);
            IChartEntity         dbChartManager      = new ChartEntity(chartSongManager, _currSettings);
            IChartBuilderService chartBuilderService = new ChartBuilderService(dbChartManager, _youtubeSearchService);

            List <System.Collections.Generic.KeyValuePair <string, string> > headers_list = new List <KeyValuePair <string, string> >();

            headers_list.Add(new KeyValuePair <string, string>("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36"));
            headers_list.Add(new KeyValuePair <string, string>("upgrade-insecure-requests", "1"));
            headers_list.Add(new KeyValuePair <string, string>("accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,* / *;q=0.8"));
            headers_list.Add(new KeyValuePair <string, string>("accept-language", "en-US,en;q=0.9"));
            headers_list.Add(new KeyValuePair <string, string>("cache-control", "max-age=0"));
            headers_list.Add(new KeyValuePair <string, string>("Proxy-Connection", "keep-alive"));

            AbstractChartDto currChart = new ChartDto();

            switch (ChartType)
            {
            case Compiler.Common.Music.ChartType.Shazam:
            {
                headers_list.Add(new KeyValuePair <string, string>("authority", "www.shazam.com"));
                headers_list.Add(new KeyValuePair <string, string>("method", "GET"));
                headers_list.Add(new KeyValuePair <string, string>("path", "/shazam/v2/en-US/US/web/-/tracks/web_chart_us"));
                headers_list.Add(new KeyValuePair <string, string>("scheme", "https"));
                IChartParser shazamParser = new ShazamParser();
                currChart = await chartBuilderService.BuildChart("https://www.shazam.com/shazam/v2/en-US/US/web/-/tracks/web_chart_us", headers_list, shazamParser);
            }
            break;

            case Compiler.Common.Music.ChartType.Billboard:
            {
                headers_list.Add(new KeyValuePair <string, string>("Referer", "http://www.billboard.com/charts"));
                IChartParser billboardParser = new BillboardParser();
                currChart = await chartBuilderService.BuildChart("http://www.billboard.com/charts/hot-100", headers_list, billboardParser);
            }
            break;

            case Compiler.Common.Music.ChartType.iTunes:
            {
                headers_list.Add(new KeyValuePair <string, string>("Referer", "https://www.apple.com/itunes/charts/"));
                IChartParser ichartParser = new iTunesParser();
                currChart = await chartBuilderService.BuildChart("https://music.apple.com/us/playlist/top-100-usa/pl.606afcbb70264d2eb2b51d8dbcfa6a12", headers_list, ichartParser);
            }
            break;

            case Compiler.Common.Music.ChartType.YouTube:
            {
                IChartParser youtubeParser = new YoutubeParser();
                currChart = await chartBuilderService.BuildChart("https://charts.youtube.com/charts/TopSongs/us ", headers_list, youtubeParser);
            }
            break;

            default:
                break;
            }

            return(Redirect("/Music/Charts"));
        }