using System;
using System.Collections.Generic;
using ReactiveUI;
using CheckArticlesForSpam.Models;
using Avalonia.Media;
using System.Linq;
using System.Net;
using System.IO;
using System.Text;
using System.Net.Http;
using Microsoft.Extensions.Options;


namespace ChecksArticlesForSpam.ViewModels
{
	public class ArticleDataPageViewModel : ReactiveObject
	{
		Article articleItem;
		string textArticle;
        string titleArticle;
		string message = "";
        private IBrush colorMessage;

        public IBrush ColorMessage { get => colorMessage; set => this.RaiseAndSetIfChanged(ref colorMessage, value); }
        public Article ArticleItem { get => articleItem; set => articleItem = value; }
        public string TextArticle { get => textArticle; set => this.RaiseAndSetIfChanged(ref textArticle, value); }
        public string TitleArticle { get => titleArticle; set => this.RaiseAndSetIfChanged(ref titleArticle, value); }
        public string Message { get => message; set => this.RaiseAndSetIfChanged(ref message, value); }

        public ArticleDataPageViewModel()
		{
			articleItem = new Article();
		}
        public ArticleDataPageViewModel(Article articleItem)
		{
			this.articleItem = articleItem;
			textArticle = articleItem.TextArticle;
			titleArticle = articleItem.Title;
		}
        public Dictionary<string, Article> GetDataArticle(User currentUser)
        {
            if (string.IsNullOrEmpty(TitleArticle)) return new Dictionary<string, Article> { { "1", null } }; 
            else if (TitleArticle.Length > 100) return new Dictionary<string, Article> { { "2", null } };
            else
            {
                ArticleItem.TextArticle = TextArticle;
                ArticleItem.UserId = currentUser.IdUser;
                ArticleItem.CheckSpam = false;
                ArticleItem.Title = TitleArticle;
                return new Dictionary<string, Article> { { "3", ArticleItem } }; ;
            }
        }
    }
}