using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using CheckArticlesForSpam.Models;
using ReactiveUI;
using Tmds.DBus.Protocol;

namespace CheckArticlesForSpam.ViewModels
{
    public class ProfileUserViewModel : ReactiveObject
    {
        string phone;
        string login;
        string password;
        string userName;
        User currentUser;
        MlgTeamContext context;
        string message;
        public ProfileUserViewModel(User currentUser, MlgTeamContext context)
        {
            this.context = context;
            this.currentUser = currentUser;
            this.phone = currentUser.Phone;
            this.login = currentUser.Login;
            this.password = currentUser.Password;
            this.UserName = currentUser.Username;
        }
        public string Message { get => message; set => this.RaiseAndSetIfChanged(ref message, value); }
        public User CurrentUser { get => currentUser; set => currentUser = value; }
        public string Phone { get => phone; set => this.RaiseAndSetIfChanged(ref phone, value); }
        public string Login { get => login; set => this.RaiseAndSetIfChanged(ref login, value); }
        public string Password { get => password; set => this.RaiseAndSetIfChanged(ref password, value); }
        public string UserName { get => userName; set => this.RaiseAndSetIfChanged(ref userName, value); }

        public User SaveChanges()
        {
            CurrentUser.Login = Login;
            CurrentUser.Password = Password;
            CurrentUser.Username = UserName;
            CurrentUser.Phone = Phone;
            context.SaveChanges();
            return CurrentUser;
        }
    }
}