예제 #1
0
 /// <summary>
 /// transfer libcard data to users and send it to the database
 /// </summary>
 /// <param name="sUID"></param>
 /// <param name="sLCID"></param>
 public bool set_libcard_to_user(string sUID, string sLCID)
 {
     try
     {
         DAL_Libcard Libcard_rep = new DAL_Libcard();
         //get user
         Account_Data user_data = retrieve_user_data(sUID);
         //get libcard
         var          libcard_response = client.Get(Libcard_rep.sLibCardTable_path + sLCID);
         LibCard_Data libcard_data     = libcard_response.ResultAs <LibCard_Data>();
         //set new data
         if (libcard_data.used == true)
         {
             return(false);
         }
         else
         {
             libcard_data.used = true;
         }
         user_data.name          = libcard_data.name;
         user_data.DOB           = libcard_data.DOB;
         user_data.gender        = libcard_data.gender;
         user_data.identity_card = libcard_data.identity_card;
         user_data.account_type  = libcard_data.account_type;
         user_data.LCID          = libcard_data.LCID;
         //send it to the database
         FirebaseResponse libcard_resp    = client.Update("LibCards/" + sLCID, libcard_data);
         FirebaseResponse update_response = client.Update(sAccountTable_path + sUID, user_data);
         Account_Data     result          = update_response.ResultAs <Account_Data>();
         if (result != null)
         {
             return(true);
         }
     }
     catch (Exception) { }
     return(false);
 }