public GeoTag getGeoTag() { try { return(ProfileTags .Select(x => x.Tag) .First(x => (x is GeoTag) && x.Description == "address") as GeoTag); } catch { return(null); } }
public List <Tag> getTags() { try { var list = ProfileTags .Select(x => x.Tag) .Where(x => !(x is GeoTag)) .OrderBy(x => x.Name) .ToList(); return(list ?? new List <Tag>()); } catch (Exception) { return(new List <Tag>()); } }
public bool LocationVerified() { if (ProfileTags == null) { return(false); } try { return(ProfileTags .Select(x => x.Tag) .OfType <GeoTag>() .First(x => x.Description.ToLower() == "address") .Name.Contains(Organization.StreetAddress)); } catch { return(false); } }
public ActionResult ProfileEditor() { var userProf = new Profile(); userProf = ReturnProfile(Session["Username"].ToString()); ViewBag.Current = userProf; //------TAGS-----\\ List <ProfileTags> list = new List <ProfileTags>(); using (var cn = new SqlConnection(Constants.ConnString)) { string _sql = @"SELECT * FROM Tags"; var cmd = new SqlCommand(_sql, cn); cn.Open(); var reader = cmd.ExecuteReader(); while (reader.Read()) { ProfileTags t = new ProfileTags { TagID = (int)reader["Id"], TagName = (string)reader["TagName"] }; list.Add(t); } cn.Close(); } var DBModel = new ProfileTagsList() { DBTags = list }; var BigModel = new BigModel { ProfileTagsList = DBModel }; //-----END TAGS-----\\ return(View(BigModel)); }
public Profile ReturnProfile(string username) { SqlDataReader reader = null; SqlConnection cn = null; SqlCommand cmd = null; cn = new SqlConnection(Constants.ConnString); string _sql = @"SELECT * FROM Profile WHERE username = @username"; cmd = new SqlCommand(_sql, cn); cmd.Parameters.AddWithValue("@username", username); cn.Open(); reader = cmd.ExecuteReader(); reader.Read(); if (reader.HasRows) { var prof = new Profile { Tags = new List <ProfileTags>() }; if (reader["username"] != null) { prof.Username = reader["username"].ToString(); } if (reader["first_name"] != null) { prof.FirstName = reader["first_name"].ToString(); } if (reader["last_name"] != null) { prof.LastName = reader["last_name"].ToString(); } if (reader["age"] != null) { prof.Age = (int)reader["age"]; } prof.Fame = prof.CalcFame(prof.Username); System.Diagnostics.Debug.WriteLine("Fame set inside ReturnProfile: " + prof.Fame); if (reader["gender"] != null) { prof.Gender = reader["gender"].ToString(); } if (reader["sexPref"] != null) { prof.SexPref = reader["sexPref"].ToString(); } if (reader["bio"] != null) { prof.Bio = reader["bio"].ToString(); } if (reader["tags"] != null) { var TagString = reader["tags"].ToString().Split(','); System.Diagnostics.Debug.WriteLine(TagString.Length.ToString()); ProfileTags newtag = new ProfileTags(); for (int i = 0; i < TagString.Length; i++) { newtag = new ProfileTags { TagName = TagString[i].ToString() }; prof.Tags.Add(newtag); } } if (reader["location"] != null) { prof.Location = reader["location"].ToString(); } if (reader["last_online"] != null) { prof.LastOnline = reader["last_online"].ToString(); } cn.Close(); System.Diagnostics.Debug.WriteLine("Profile Returned"); return(prof); } else { cn.Close(); return(null); } }