Beispiel #1
0
 /// <summary>
 /// Overload of the constructor. Receives a IdUser and populates the instance with its values.
 /// </summary>
 /// <param name="id">The IdUser of the user to retrieve information from.</param>
 public User(int id)
 {
     List<Dictionary<string, string>> user = Common.GetRS("SELECT * FROM Users WHERE IdUser = "******"IdExternal"];
         Username = record["Username"];
         Password = record["Password"];
         Name = record["Name"];
         LastName = record["LastName"];
         MotherLastName = record["MotherLastName"];
         Status = Convert.ToInt32(record["Status"]);
         RegistryDate = Convert.ToDateTime(record["RegistryDate"]);
         PrivacyAccepted = Convert.ToInt32(record["PrivacyAccepted"]);
         IdRole = Common.GetBDNum("IdRole", "SELECT IdRole FROM UserRoles WHERE IdUser = "******"SELECT * FROM UserData WHERE IdUser = "******"IdData"]));
         userDataList.Add(userData);
     }
 }
Beispiel #2
0
 /// <summary>
 /// Attempts to update the user fields.
 /// </summary>
 /// <returns>If an error is found, returns the description, otherwise it returns an empty string.</returns>
 public string UpdateUserFields()
 {
     string errorMsg = "";
     bool requiredFieldsSet = true;
     List<DataDesc> dataDescList = Data.Data.GetDataDesc();
     foreach (DataDesc dataDesc in dataDescList)
     {
         UserData userData = new UserData(IdUser, dataDesc.IdData);
         userData.Value = HttpContext.Current.Request.Form["data_" + dataDesc.IdData];
         if (!dataDesc.IsValid(userData.Value) && dataDesc.Required == 1)
         {
             requiredFieldsSet = false;
             errorMsg = Text.RequiredFieldsMissing + "<br>";
         }
     }
     foreach (DataDesc dataDesc in dataDescList)
     {
         UserData userData = new UserData(IdUser, dataDesc.IdData);
         userData.Value = HttpContext.Current.Request.Form["data_" + dataDesc.IdData];
         if (dataDesc.IsValid(userData.Value))
         {
             if(requiredFieldsSet) userData.Update();
         }
         else
         {
             errorMsg = Common.StrAdd(errorMsg, "<br>", dataDesc.GetErrorMessage());
         }
     }
     if (!String.IsNullOrEmpty(errorMsg)) errorMsg += "<br>" + Text.ChangesNotSaved;
     return errorMsg;
 }