public ContactMaster Get(int Id)
        {
            SqlConnection con   = new SqlConnection("Data Source=DESKTOP-3LQJUUD;Initial Catalog=SchoolDB;User ID=sa;Password=123");
            string        query = "Select * from dbo.ContactMaster Where Id = @Id";
            SqlCommand    cmd   = new SqlCommand(query, con);

            cmd.Parameters.AddWithValue("@Id", Id);
            con.Open();
            ContactMaster contactMaster = null;
            SqlDataReader dr            = cmd.ExecuteReader();

            if (dr.Read())
            {
                contactMaster = new ContactMaster
                {
                    Id             = (int)dr[0],
                    ContactDetails = dr[1].ToString(),
                    PhoneNumber    = (int)dr[2],
                    MobileNumber   = (int)dr[3],
                    CreatedBy      = (int)dr[4],
                };
                con.Close();
            }
            return(contactMaster);
        }
        public List <ContactMaster> GetAll()
        {
            SqlConnection con   = new SqlConnection("Data Source=DESKTOP-3LQJUUD;Initial Catalog=SchoolDB;User ID=sa;Password=123");
            string        query = "Select * from dbo.ContactMaster";
            SqlCommand    cmd   = new SqlCommand(query, con);

            con.Open();
            List <ContactMaster> contactMasters = new List <ContactMaster>();
            SqlDataReader        dr             = cmd.ExecuteReader();

            while (dr.Read())
            {
                ContactMaster contact = new ContactMaster()
                {
                    Id             = (int)dr[0],
                    ContactDetails = dr[1].ToString(),
                    PhoneNumber    = (int)dr[2],
                    MobileNumber   = (int)dr[3],
                    CreatedBy      = (int)dr[4],
                };
                contactMasters.Add(contact);
            }
            con.Close();
            return(contactMasters);
        }
        public bool Post(ContactMaster contactMaster)
        {
            SqlConnection con   = new SqlConnection("Data Source=DESKTOP-3LQJUUD;Initial Catalog=SchoolDB;User ID=sa;Password=123");
            string        query = "Insert into dbo.ContactMaster (ContactDetails,PhoneNumber,MobileNUmber,CreatedBy) Values(@ContactDetails,@PhoneNumber,@MobileNumber,@CreatedBy)";
            SqlCommand    cmd   = new SqlCommand(query, con);

            cmd.Parameters.AddWithValue("@ContactDetails", contactMaster.ContactDetails);
            cmd.Parameters.AddWithValue("@PhoneNumber", contactMaster.PhoneNumber);
            cmd.Parameters.AddWithValue("@MobileNumber", contactMaster.MobileNumber);
            cmd.Parameters.AddWithValue("@CreatedBy", contactMaster.CreatedBy);
            con.Open();
            int noOfRowAffected = cmd.ExecuteNonQuery();

            con.Close();
            if (noOfRowAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }