public ImageResultSubForm(BitmapSymbol unknown, ImageScore template)
        {
            InitializeComponent();

            ImageScore score = template;

            labelNames.Text              = score.SymbolClass + ": " + score.SymbolType;
            labelHausdorff.Text         += score.HausdorfScore.ToString("#0.000");
            labelModifiedHausdorff.Text += score.ModifiedHausdorfScore.ToString("#0.000");
            labelTanimoto.Text          += score.TanimotoScore.ToString("#0.000");
            labelYule.Text         += score.YuleScore.ToString("#0.000");
            labelUserName.Text     += score.UserName;
            labelCompleteness.Text += score.Completeness.ToString();
            labelPlatform.Text     += score.Platform.ToString();

            InkOverlay ink = new InkOverlay(panelInk);

            foreach (Point[] pts in unknown.Points)
            {
                ink.Ink.CreateStroke(pts);
                ink.Ink.Strokes[ink.Ink.Strokes.Count - 1].DrawingAttributes.Color = Color.Blue;
            }
            ScaleAndMoveInk(ref ink);

            InkOverlay     symbolInk = new InkOverlay(panelInk);
            List <Point[]> strokes   = score.TemplateSymbol.Points;

            foreach (Point[] points in strokes)
            {
                symbolInk.Ink.CreateStroke(points);
                symbolInk.Ink.Strokes[symbolInk.Ink.Strokes.Count - 1].DrawingAttributes.Color = Color.Red;
            }
            ScaleAndMoveInk(ref symbolInk);
        }
        //[Authorize(Roles = "Admin")]
        public async Task <IActionResult> UpdateImageScore([FromForm] ImageScore imageScore)
        {
            var success = await _imageScoreApp.UpdateImageScore(imageScore);

            if (!success)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }

            return(Ok());
        }
        public async Task <ImageScore> GetImageScore()
        {
            var scores = await _context.ImageScores.FirstOrDefaultAsync();

            if (scores == null)
            {
                scores = new ImageScore()
                {
                    Drawings  = 0,
                    Hentai    = 0.2,
                    Neutral   = 0,
                    P**n      = 0.2,
                    Sexy      = 0.5,
                    UpdatedAt = DateTime.Now
                };

                _context.ImageScores.Add(scores);
                await SaveChangesAsync();
            }
            return(scores);
        }
        public async Task <bool> UpdateImageScore(ImageScore update)
        {
            var scores = await GetImageScore();

            scores.Drawings = update.Drawings;
            if (update.P**n >= 0 && update.P**n <= 100)
            {
                scores.P**n = update.P**n;
            }

            if (update.Sexy >= 0 && update.Sexy <= 100)
            {
                scores.Sexy = update.Sexy;
            }

            if (update.Hentai >= 0 && update.Hentai <= 100)
            {
                scores.Hentai = update.Hentai;
            }

            scores.Neutral    = update.Neutral;
            scores.UpdatedAt  = DateTime.Now;
            scores.AutoFilter = update.AutoFilter;
            scores.Active     = update.Active;

            _context.ImageScores.Update(scores);

            try
            {
                await SaveChangesAsync();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }