using LSFE.MobApp.Models;
using LSFE.MobApp.ViewModels.Authentication;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LSFE.MobApp.Services.Authentication
{
    public static class UserCred
    {
        public static async Task <LoginResponse> GetUserCred()
        {
            var user = new LoginResponse
            {
                UserId= await SecureStorage.GetAsync("user_id"),
                UserName= await SecureStorage.GetAsync("username"),
                Token = await SecureStorage.GetAsync("auth_token"),
                Password = await SecureStorage.GetAsync("password"),
            };
            return await Task.FromResult(user);
        }
        public static async Task<LoginResponse> SetUserCred(LoginResponse login)
        {
            await SecureStorage.SetAsync("auth_token", login.Token ?? "N/A");
            await SecureStorage.SetAsync("user_id", login.UserId);
            await SecureStorage.SetAsync("username", login.UserName);
            await SecureStorage.SetAsync("password", login.Password);
            await SecureStorage.SetAsync("device_registered", login.IsDeviceRegister.ToString());
            return login;
        }
    }
}
