/// <summary> /// Register - build from serialized dictionary of customer info and /// pass dictionary to partner model object. Receives valid customerid or -1 if /// validation fails /// </summary> public void Register() { Dictionary<string, Object> dictionaryCustomer = new Dictionary<string, Object>(); try { CustomerModel myData = new CustomerModel(); dictionaryCustomer["username"] = Username; dictionaryCustomer["firstname"] = Firstname; dictionaryCustomer["lastname"] = Lastname; dictionaryCustomer["age"] = Age; dictionaryCustomer["address1"] = Address1; dictionaryCustomer["city"] = City; dictionaryCustomer["mailcode"] = Mailcode; dictionaryCustomer["region"] = Region; dictionaryCustomer["email"] = Email; dictionaryCustomer["country"] = Country; dictionaryCustomer["creditcardtype"] = CreditcardType; CustomerID = myData.Register(Serializer(dictionaryCustomer)); Message = "Customer " + CustomerID + " registered!"; } catch (Exception ex) { Message = "Customer not registered, problem was " + ex.Message; ErrorRoutine(ex, "CustomerViewModel", "Register"); } }
/// <summary> /// GetCurrentProfile - obtain Customer Row row from data object and populate member vars /// </summary> public void GetCurrentProfile() { try { CustomerModel myData = new CustomerModel(); Dictionary<string, Object> dictionaryCustomer = new Dictionary<string, Object>(); dictionaryCustomer = (Dictionary<string, Object>)Deserializer(myData.GetCurrentProfile(Username)); Firstname = Convert.ToString(dictionaryCustomer["firstname"]); Lastname = Convert.ToString(dictionaryCustomer["lastname"]); Username = Convert.ToString(dictionaryCustomer["username"]); Email = Convert.ToString(dictionaryCustomer["email"]); Age = Convert.ToInt32(dictionaryCustomer["age"]); Address1 = Convert.ToString(dictionaryCustomer["address1"]); City = Convert.ToString(dictionaryCustomer["city"]); Mailcode = Convert.ToString(dictionaryCustomer["mailcode"]); Region = Convert.ToString(dictionaryCustomer["region"]); Country = Convert.ToString(dictionaryCustomer["country"]); CreditcardType = Convert.ToString(dictionaryCustomer["creditcardtype"]); CustomerID = Convert.ToInt32(dictionaryCustomer["customerid"]); } catch (Exception ex) { ErrorRoutine(ex, "CustomerViewModel", "GetCurrentProfile"); } }