-7

I'm trying to build a three piece Streaming Project in which I need to build an API that is already working, a Java App for Android that I haven't even started and this .NET MAUI using C# that is giving me headaches, whenever I run the command "dotnet build" I get the same error for multiple ViewModels:

Error CS0246: The name or type of the namespace "ICommandAttribute" can't be found or treated (missing using or assembly reference?)

This is my code:

using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using PimStreamingApp.Maui.Services;

namespace PimStreamingApp.Maui.ViewModels;

public partial class LoginViewModel : ObservableObject
{
    private readonly IAuthService _authService;

    [ObservableProperty] private string email = "";
    [ObservableProperty] private string password = "";
    [ObservableProperty] private bool isBusy;

    public LoginViewModel(IAuthService authService)
    {
        _authService = authService;
    }

    [ICommand]
    private async Task LoginAsync()
    {
        if (IsBusy) 
            return;

        IsBusy = true;

        try
        {
            var token = await _authService.LoginAsync(Email, Password);

            if (!string.IsNullOrEmpty(token))
            {
                await Shell.Current.GoToAsync("//dashboard");
            }
            else
            {
                await Application.Current.MainPage.DisplayAlert("Erro", "Credenciais inválidas", "OK");
            }
        }
        finally
        {
            IsBusy = false;
        }
    }

    [ICommand]
    private async Task RegisterAsync()
    {
        // abre página de registro se existir
        await Application.Current.MainPage.DisplayAlert("Info", "Use o Swagger para registrar (ou implemente RegisterPage).", "OK");
    }
}

Right here is one of the view models I've built.

Any answer is helpful, thanks

The repo can be found at https://github.com/p3dromelo/PimStreamingApp.Maui if anyone wants to check it further.

New contributor
Pedro is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.