//User clicked on link //We shall update the database to validate his/her account using the provided token public static Profile ValidateProfile(Guid Token) { Profile profile = null; try { var DAL = new DataAccess(); var dt = DAL.select(String.Format("ValidationToken = '{0}'", Token), "UserProfile", NumRows: 1); if (dt != null && dt.Rows.Count > 0) { var updateDictionary = new Dictionary<string, object>(); updateDictionary.Add("IsValid", true); DAL.update("UserProfile", "ValidationToken = '{0}'", updateDictionary); var row = dt.Rows[0]; var UserName = Convert.ToString(row["UserName"]); var profileId = Convert.ToInt32(row["UserId"]); var displayName = Convert.ToString(row["DisplayName"]); var facebookId = row["FacebookId"] is DBNull ? null : Convert.ToString(row["FacebookId"]); var facebookLink = row["FacebookLink"] is DBNull ? null : Convert.ToString(row["FacebookLink"]); profile = new Profile(profileId, displayName, UserName, facebookId, facebookLink); } } catch (Exception ex) { Console.Write("ERROR: An error occured in retrieving the user profile --- " + ex.Message); } return profile; }
public static void UpdateTransaction(int transactionId, Dictionary<string, object> updateDictionary) { DataAccess da = new DataAccess(); da.update("Transactions", String.Format("TransactionId = {0}", transactionId), updateDictionary); }
public static bool updatePostState(int postId, int isTransacting, int? isActive = null) { bool success = true; try { Dictionary<string, object> updateDict = new Dictionary<string, object>(); updateDict.Add("IsTransacting", isTransacting); if (isActive != null) { updateDict.Add("IsActive", isActive); } DataAccess da = new DataAccess(); da.update("Posts", String.Format("PostId = {0}", postId), updateDict); } catch (Exception e) { Console.Write("ERROR: Could not update post state with the given post id --- " + e.Message); success = false; } return success; }