/// <summary> /// Create a new tblProfiles object. /// </summary> /// <param name="id">Initial value of Id.</param> /// <param name="userName">Initial value of UserName.</param> /// <param name="propertyNames">Initial value of PropertyNames.</param> /// <param name="propertyValues">Initial value of PropertyValues.</param> /// <param name="lastUpdatedDate">Initial value of LastUpdatedDate.</param> public static tblProfiles CreatetblProfiles(int id, string userName, string propertyNames, string propertyValues, global::System.DateTime lastUpdatedDate) { tblProfiles tblProfiles = new tblProfiles(); tblProfiles.Id = id; tblProfiles.UserName = userName; tblProfiles.PropertyNames = propertyNames; tblProfiles.PropertyValues = propertyValues; tblProfiles.LastUpdatedDate = lastUpdatedDate; return tblProfiles; }
public override void SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection collection) { var username = (string) context["UserName"]; var userIsAuthenticated = (bool) context["IsAuthenticated"]; if (string.IsNullOrEmpty(username) || collection.Count < 1) return; var db = new MyLifeEntities(); var profile = db.tblProfiles.Where(item => item.UserName == username).FirstOrDefault(); if (profile == null) { profile = new tblProfiles {LastUpdatedDate = DateTime.UtcNow}; db.AddTotblProfiles(profile); profile.UserName = username.ToLowerInvariant(); } var names = new StringBuilder(); var values = new StringBuilder(); foreach (SettingsPropertyValue property in collection) { var name = property.Name; var value = property.PropertyValue; var allowAnonymous = (bool) property.Property.Attributes["AllowAnonymous"]; if (!userIsAuthenticated && !allowAnonymous) continue; if (value == null) continue; names.Append(name).Append(";#"); values.Append(Base64Serializer.Serialize(value)).Append(";#"); } profile.PropertyNames = names.ToString(); profile.PropertyValues = values.ToString(); profile.LastUpdatedDate = DateTime.UtcNow; db.SaveChanges(); }
/// <summary> /// There are no comments for tblProfiles in the schema. /// </summary> public void AddTotblProfiles(tblProfiles tblProfiles) { base.AddObject("tblProfiles", tblProfiles); }