Please tell me what is wrong with the codes. It says that Inconsistent accessibility: return type 'Task<Citizen>' is less accessible than method 'AdminPage.GetCitizen(string)'

Silwin Benito 21 Reputation points
2021-07-15T18:57:23.44+00:00

using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using FireSharp.Config;
using FireSharp.Interfaces;
using FireSharp.Response;
using FireSharp.Serialization;

namespace ContactTracing
{
public partial class AdminPage : Form
{

    public AdminPage()
    {
        InitializeComponent();
    }


    private async void AdminPage_Load(object sender, EventArgs e)
    {


        if (UtilityClass.IsCheckInternet())
        {
            GetAllCitizen();
        }
        else
        {
            MessageBox.Show(text:@"Please check your internet connection", caption:@"Warning",MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }



    }

    private async void bunifuButton1_Click_1(object sender, EventArgs e)
    {
        if (bunifuTextBox2.Text.Trim() == String.Empty)
        {
            MessageBox.Show(text: "Please input!", caption: "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            bunifuTextBox2.Focus();
            return;
        }

        Citizen aCitizen = new Citizen();

        aCitizen.c_id = Citizen_ID.Text;
        aCitizen.f_name = bunifuTextBox2.Text;
        aCitizen.m_name = bunifuTextBox3.Text;
        aCitizen.l_name = bunifuTextBox4.Text;
        aCitizen.c_username = bunifuTextBox5.Text;
        aCitizen.c_password = bunifuTextBox6.Text;

        aCitizen.c_qrstatus = bunifuTextBox7.Text;
        aCitizen.c_acc_status = bunifuTextBox8.Text;
        aCitizen.c_qrlink = bunifuTextBox9.Text;
        aCitizen.c_file_link = bunifuTextBox10.Text;
        aCitizen.c_profile_link = bunifuTextBox11.Text;

        aCitizen.bdate = bunifuTextBox12.Text;
        aCitizen.gender = bunifuTextBox13.Text;
        aCitizen.cstatus = bunifuTextBox14.Text;

        //Adress
        aCitizen.province = bunifuTextBox15.Text;
        aCitizen.district = bunifuTextBox16.Text;
        aCitizen.city = bunifuTextBox17.Text;
        aCitizen.brgy = bunifuTextBox18.Text;
        aCitizen.strt_lot_blk = bunifuTextBox19.Text;
        aCitizen.other_d = bunifuTextBox20.Text;

        //Email and contact
        aCitizen.email = bunifuTextBox21.Text;
        aCitizen.contact_no = bunifuTextBox22.Text;

        IFirebaseConfig config = new FirebaseConfig()
        {
            AuthSecret = "yQ6fO8hohS4N5JMSKSCdvDuVjbC5klfZOv3kQUlL",
            BasePath = "https://project-757ec-default-rtdb.asia-southeast1.firebasedatabase.app/"
        };

        IFirebaseClient client = new FireSharp.FirebaseClient(config);

        if (UtilityClass.IsCheckInternet())
        {
            if (bunifuButton1.Text == @"Save")
            {
                PushResponse message = await client.PushAsync(path: "Citizen", aCitizen);
                if (message.Body != null)
                {
                    MessageBox.Show(text: "Citizen information has been saved", caption: "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Reset();
                    GetAllCitizen();
                }
                else
                {
                    MessageBox.Show(text: "Citizen information has not been saved", caption: "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            if (bunifuButton1.Text == @"Update")
            {
                var message = await client.UpdateAsync(path: "Citizen/" + aCitizen.c_id, aCitizen);
                if (message.Body != null)
                {
                    MessageBox.Show(text: "Citizen information has been updated", caption: "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Reset();
                    GetAllCitizen();
                }
                else
                {
                    MessageBox.Show(text: "Citizen information has not been updated", caption: "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        else
        {
            MessageBox.Show(text: @"Please check your internet connection", caption: @"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }




    }



    private void Reset()
    {
        Citizen_ID.Text = "";
        bunifuTextBox2.Clear();
        bunifuTextBox3.Clear();
        bunifuTextBox4.Clear();
        bunifuTextBox5.Clear();
        bunifuTextBox6.Clear();

        bunifuTextBox7.Clear();
        bunifuTextBox8.Clear();
        bunifuTextBox9.Clear();
        bunifuTextBox10.Clear();
        bunifuTextBox11.Clear();

        bunifuTextBox12.Clear();
        bunifuTextBox13.Clear();
        bunifuTextBox14.Clear();


        bunifuTextBox15.Clear();
        bunifuTextBox16.Clear();
        bunifuTextBox17.Clear();
        bunifuTextBox18.Clear();
        bunifuTextBox19.Clear();
        bunifuTextBox20.Clear();


        bunifuTextBox21.Clear();
        bunifuTextBox22.Clear();
    }

    private void CitizenDataGridView_DoubleClick(object sender, EventArgs e)
    {



    }

    private async void CitizenDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
    {
        if (e.RowIndex >= 0)
        {
            //gets a collection that contains all the rows
            DataGridViewRow row = this.CitizenDataGridView.Rows[e.RowIndex];
            //populate the textbox from specific value of the coordinates of column and row.
            string id = row.Cells[0].Value.ToString();
            Citizen aCitizen = await GetCitizen(id);
            Citizen_ID.Text = aCitizen.c_id;
            bunifuTextBox2.Text = aCitizen.f_name;
            bunifuTextBox3.Text = aCitizen.m_name;
            bunifuTextBox4.Text = aCitizen.l_name;
            bunifuTextBox5.Text = aCitizen.c_username;
            bunifuTextBox6.Text = aCitizen.c_password;
            bunifuTextBox7.Text = aCitizen.c_qrstatus;
            bunifuTextBox8.Text = aCitizen.c_acc_status;
            bunifuTextBox9.Text = aCitizen.c_qrlink;
            bunifuTextBox10.Text = aCitizen.c_file_link;
            bunifuTextBox11.Text = aCitizen.c_profile_link;
            bunifuTextBox12.Text = aCitizen.bdate;
            bunifuTextBox13.Text = aCitizen.gender;
            bunifuTextBox14.Text = aCitizen.cstatus;
            bunifuTextBox15.Text = aCitizen.province;
            bunifuTextBox16.Text = aCitizen.district;
            bunifuTextBox17.Text = aCitizen.city;
            bunifuTextBox18.Text = aCitizen.brgy;
            bunifuTextBox19.Text = aCitizen.strt_lot_blk;
            bunifuTextBox20.Text = aCitizen.other_d;
            bunifuTextBox21.Text = aCitizen.email;
            bunifuTextBox22.Text = aCitizen.contact_no;


            bunifuTextBox2.Text = row.Cells[1].Value.ToString();
            bunifuTextBox3.Text = row.Cells[2].Value.ToString();
            bunifuTextBox4.Text = row.Cells[3].Value.ToString();
            bunifuTextBox5.Text = row.Cells[4].Value.ToString();
            bunifuTextBox6.Text = row.Cells[5].Value.ToString();
            bunifuTextBox7.Text = row.Cells[6].Value.ToString();
            bunifuTextBox8.Text = row.Cells[7].Value.ToString();
            bunifuTextBox9.Text = row.Cells[8].Value.ToString();
            bunifuTextBox10.Text = row.Cells[9].Value.ToString();
            bunifuTextBox11.Text = row.Cells[10].Value.ToString();
            bunifuTextBox12.Text = row.Cells[11].Value.ToString();
            bunifuTextBox13.Text = row.Cells[12].Value.ToString();
            bunifuTextBox14.Text = row.Cells[13].Value.ToString();
            bunifuTextBox15.Text = row.Cells[14].Value.ToString();
            bunifuTextBox16.Text = row.Cells[15].Value.ToString();
            bunifuTextBox17.Text = row.Cells[16].Value.ToString();
            bunifuTextBox18.Text = row.Cells[17].Value.ToString();
            bunifuTextBox19.Text = row.Cells[18].Value.ToString();
            bunifuTextBox20.Text = row.Cells[19].Value.ToString();
            bunifuTextBox21.Text = row.Cells[20].Value.ToString();
            bunifuTextBox22.Text = row.Cells[21].Value.ToString();

            bunifuButton1.Text = "Update";
        }
    }

//This part where i get the error

    **public async Task<Citizen> GetCitizen(string id)
    {
        IFirebaseConfig config = new FirebaseConfig()
        {
            AuthSecret = "yQ6fO8hohS4N5JMSKSCdvDuVjbC5klfZOv3kQUlL",
            BasePath = "https://project-757ec-default-rtdb.asia-southeast1.firebasedatabase.app/"
        };
        IFirebaseClient client = new FireSharp.FirebaseClient(config);
        var data = await client.GetAsync(path: "Citizen/" + c_id);
        Citizen aCitizen = new Citizen();
        if (data.Body != "null")
        {
            aCitizen = data.ResultAs<Citizen>();
            aCitizen.c_id = id;
        }
        return aCitizen;
    }**



public async void GetAllCitizen()
    {
        IFirebaseConfig config = new FirebaseConfig()
        {
            AuthSecret = "yQ6fO8hohS4N5JMSKSCdvDuVjbC5klfZOv3kQUlL",
            BasePath = "https://project-757ec-default-rtdb.asia-southeast1.firebasedatabase.app/"
        };

        IFirebaseClient client = new FireSharp.FirebaseClient(config);

        var data = await client.GetAsync(path: "Citizen");

        if (data.Body != "null")
        {
            Dictionary<string, Citizen> citizens = data.ResultAs<Dictionary<string, Citizen>>();

            foreach (var citizen in citizens)
            {
                CitizenDataGridView.Rows.Add(citizen.Key, citizen.Value.f_name, citizen.Value.m_name, citizen.Value.l_name, citizen.Value.c_username, citizen.Value.c_password, citizen.Value.c_qrstatus, citizen.Value.c_acc_status, citizen.Value.c_qrlink, citizen.Value.c_file_link, citizen.Value.c_profile_link, citizen.Value.bdate, citizen.Value.gender, citizen.Value.cstatus, citizen.Value.province, citizen.Value.district, citizen.Value.city, citizen.Value.brgy, citizen.Value.strt_lot_blk, citizen.Value.other_d, citizen.Value.email, citizen.Value.contact_no);
            }
        }
    }




}
}
Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,869 questions
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 114.4K Reputation points
    2021-07-15T19:44:07.64+00:00

    Make sure that Citizen is a public class. (Or adjust the accessibility of GetCitizen, if possible).


0 additional answers

Sort by: Most helpful