public void changeDefault(HttpPostedFileBase file) { byte[] data; using (Stream inputStram = file.InputStream) { MemoryStream memorystram = inputStram as MemoryStream; if (memorystram == null) { memorystram = new MemoryStream(); inputStram.CopyTo(memorystram); } profileDal pdal = new profileDal(); Profile profile = new Profile(); data = memorystram.ToArray(); profile.username = "******"; profile.biography = "empty"; profile.image = data; pdal.profilesList.RemoveRange(pdal.profilesList.Where(x => x.username.Equals("testImage"))); pdal.profilesList.Add(profile); try { pdal.SaveChanges(); } catch (Exception e) { Console.WriteLine(e.Message); } } }
public ActionResult editProfilePhoto(HttpPostedFileBase file) { byte[] data; using (Stream inputStram = file.InputStream) { MemoryStream memorystram = inputStram as MemoryStream; if (memorystram == null) { memorystram = new MemoryStream(); inputStram.CopyTo(memorystram); } profileDal pdal = new profileDal(); Profile profile = GetProfile(); data = memorystram.ToArray(); profile.image = data; pdal.profilesList.RemoveRange(pdal.profilesList.Where(x => x.username == profile.username)); pdal.SaveChanges(); pdal.profilesList.Add(profile); try { Console.WriteLine("DONE"); pdal.SaveChanges(); } catch (Exception e) { Console.WriteLine(e.Message); } } return(RedirectToAction("MyProfile", "User")); }
public ActionResult DeleteUser(string delete) { profileDal pdal = new profileDal(); UsersStatusDal usdal = new UsersStatusDal(); notificationsDal ndal = new notificationsDal(); friendsDal fdal = new friendsDal(); String toDelete; try { toDelete = Request.Form["row"].ToString(); } catch (Exception) { toDelete = delete; } udal.userLst.RemoveRange(udal.userLst.Where(x => x.username.Equals(toDelete))); adal.adminsLst.RemoveRange(adal.adminsLst.Where(x => x.username.Equals(toDelete))); pdal.profilesList.RemoveRange(pdal.profilesList.Where(x => x.username.Equals(toDelete))); usdal.statuses.RemoveRange(usdal.statuses.Where(x => x.username.Equals(toDelete))); ndal.nLst.RemoveRange(ndal.nLst.Where(x => x.username.Equals(toDelete) || x.uFrom.Equals(toDelete))); fdal.FriendsLst.RemoveRange(fdal.FriendsLst.Where(x => x.username.Equals(toDelete))); fdal.FriendsLst.RemoveRange(fdal.FriendsLst.Where(x => x.friendUsername.Equals(toDelete))); udal.SaveChanges(); adal.SaveChanges(); pdal.SaveChanges(); usdal.SaveChanges(); ndal.SaveChanges(); fdal.SaveChanges(); return(RedirectToAction("usersList", "Admin")); }
public ActionResult DeleteFriend(string username) { List <userMoments> myList = (List <userMoments>)Session["UsersList"]; List <Profile> SELECTEDLIST = (List <Profile>)Session["SelectedList"]; List <Profile> templist = SELECTEDLIST; userMomentDal usermdal = new userMomentDal(); profileDal pDal = new profileDal(); var idtodelete = 0; foreach (var x in myList) { if (x.username == username) { idtodelete = x.id; } } var ifuserexit = usermdal.userMomentLST.Where(x => (username == x.username) && x.uType == "User" && idtodelete == x.id).SingleOrDefault(); if (ifuserexit != null) { usermdal.userMomentLST.RemoveRange(usermdal.userMomentLST.Where(x => (x.id == idtodelete) && (x.username == username))); usermdal.SaveChanges(); Profile todelete = templist.Find(x => x.username == username); templist.Remove(todelete); } else { TempData["CurrentMessage"] = "You Cant Delete Your Self From This Group!"; return(View("View_All_Group_Members", SELECTEDLIST)); } return(View("View_All_Group_Members", templist)); }
public ActionResult editProfile() { string firstname = Request.Form["firstName"].ToString(); string lastname = Request.Form["lastName"].ToString(); string bio = Request.Form["biography"].ToString(); string pass = Request.Form["password"].ToString(); string repass = Request.Form["repassword"].ToString(); Profile oldDBProfile = GetProfile(); users oldDBUser = GetUser(); oldDBUser.firstName = firstname; oldDBUser.lastName = lastname; oldDBProfile.biography = bio; if (pass != "" && pass == repass) { oldDBUser.password = pass; } else if (pass != "" && pass != repass) { TempData["ERROR"] = "Unmatched Passwords! , try again."; } usersDal udal = new usersDal(); profileDal pdal = new profileDal(); udal.userLst.RemoveRange(udal.userLst.Where(x => x.username == oldDBUser.username)); udal.SaveChanges(); udal.userLst.Add(oldDBUser); udal.SaveChanges(); pdal.profilesList.RemoveRange(pdal.profilesList.Where(x => x.username == oldDBProfile.username)); pdal.SaveChanges(); pdal.profilesList.Add(oldDBProfile); pdal.SaveChanges(); return(RedirectToAction("MyProfile", "User")); }
public ActionResult Delete(String id) { String uname = Session["CurrentUsername"].ToString(); friendsDal fDal = new friendsDal(); List <Friends> friendsd = (from x in fDal.FriendsLst where (x.username.Equals(uname) && x.friendUsername.Equals(id)) || (x.friendUsername.Equals(uname) && x.username.Equals(id)) select x).ToList <Friends>(); fDal.FriendsLst.Remove(friendsd[0]); fDal.SaveChanges(); List <String> friends1 = (from x in fDal.FriendsLst where x.username.Equals(uname) select x.friendUsername).ToList <String>(); List <String> friends2 = (from x in fDal.FriendsLst where x.friendUsername.Equals(uname) select x.username).ToList <String>(); IEnumerable <String> friends = friends1.Union(friends2); profileDal pDal = new profileDal(); List <Profile> profiles = (from x in pDal.profilesList where friends.Contains <String>(x.username) select x).ToList <Profile>(); return(View("MyFriends", profiles)); }
public Profile GetProfile() { profileDal dal = new profileDal(); string currentuser = Session["CurrentUsername"].ToString(); List <Profile> curr = (from x in dal.profilesList where x.username == currentuser select x).ToList <Profile>(); return(curr[0]); }
public ActionResult RegAction(users userReg) { usersDal emails = new usersDal(); profileDal pdal = new profileDal(); UsersStatusDal usdal = new UsersStatusDal(); List <users> checkLSt = (from tmp in emails.userLst where tmp.email.Contains(userReg.email) select tmp).ToList <users>(); if (checkLSt.Count > 0) { ViewData["eMess"] = "This e-mail has registered before\n try another one."; } else { if (userReg.password != Request.Form["rePass"]) { ViewData["pMess"] = "The passwords doesn't match"; } else if (userReg.password.Length < 6) { ViewData["pMess"] = "The password length must be greater than 6"; } else { Profile profile = new Profile(); usersStatus uss = new usersStatus(); List <Profile> defProfile = (from x in pdal.profilesList where x.username.Equals("testImage") select x).ToList <Profile>(); emails.userLst.Add(userReg); emails.SaveChanges(); profile.username = userReg.username; profile.biography = "empty"; profile.image = defProfile[0].image; pdal.profilesList.Add(profile); uss.username = userReg.username; uss.status = "Activated"; usdal.statuses.Add(uss); usdal.SaveChanges(); try { pdal.SaveChanges(); } catch (Exception e) { Console.WriteLine(e.Message); } return(View("Login")); } } return(View("Register")); }
public ActionResult AddFriend(String id) { notificationsDal nDal = new notificationsDal(); List <Notifications> tmp = (from x in nDal.nLst select x).ToList <Notifications>(); int size = tmp.Count(); Notifications newNoti = new Notifications(); newNoti.username = id; newNoti.status = "Not Accepted"; newNoti.uFrom = Session["CurrentUsername"].ToString(); newNoti.dateSent = DateTime.Now; newNoti.type = "Friend Request"; newNoti.id = size + 1; nDal.nLst.Add(newNoti); nDal.SaveChanges(); friendsDal fDal = new friendsDal(); String uname = Session["CurrentUsername"].ToString(); List <Friends> friends1 = (from x in fDal.FriendsLst where x.username.Equals(uname) select x).ToList <Friends>(); List <Friends> friends2 = (from x in fDal.FriendsLst where x.friendUsername.Equals(uname) select x).ToList <Friends>(); IEnumerable <Friends> friendAll = friends1.Union(friends2); List <String> friends = new List <string>(); foreach (var f in friendAll) { if (f.username.Equals(uname)) { friends.Add(f.friendUsername); } else { friends.Add(f.username); } } //IEnumerable<Friends> friends = friends1.Union(friends2); profileDal pDal = new profileDal(); List <Profile> profiles = (from x in pDal.profilesList where friends.Contains <String>(x.username) select x).ToList <Profile>(); return(View("MyFriends", profiles)); }
public ActionResult RedirectToProfile() { string usr = Request.Form["usr"].ToString(); usersDal uDal = new usersDal(); UserViewModel view = new UserViewModel(); profileDal pDal = new profileDal(); List <Profile> profile = (from x in pDal.profilesList where x.username.Equals(usr) select x).ToList <Profile>(); List <users> u = (from x in uDal.userLst where x.username.Equals(usr) select x).ToList <users>(); view.profile = profile[0]; view.user = u[0]; return(View(view)); //return RedirectToAction("ViewFriendProfile", "Profile", usrname); }
public ActionResult searchByUsrName(String text) { //search profile, not user profileDal pDal = new profileDal(); string usrName; try { usrName = Request.Form["text"].ToString(); } catch { usrName = text; } List <Profile> profiles = (from x in pDal.profilesList where x.username.StartsWith(usrName) select x).ToList <Profile>(); return(View(profiles)); }
public ActionResult MyFriends() { classActive("friendsActive"); friendsDal fDal = new friendsDal(); String uname = Session["CurrentUsername"].ToString(); Debug.WriteLine(uname); List <Friends> friends1 = (from x in fDal.FriendsLst where x.username.Equals(uname) select x).ToList <Friends>(); List <Friends> friends2 = (from x in fDal.FriendsLst where x.friendUsername.Equals(uname) select x).ToList <Friends>(); IEnumerable <Friends> friendAll = friends1.Concat <Friends>(friends2); List <String> friends = new List <string>(); foreach (var f in friendAll) { if (f.username.Equals(uname)) { friends.Add(f.friendUsername); } else { friends.Add(f.username); } } //Debug.WriteLine(friends[0]); //IEnumerable<Friends> friends = friends1.Union(friends2); profileDal pDal = new profileDal(); List <Profile> profiles = (from x in pDal.profilesList where friends.Contains <String>(x.username) select x).ToList <Profile>(); return(View(profiles)); }
public ActionResult View_All_Group_Members(int mid1) { profileDal pDal = new profileDal(); userMomentDal usermdal = new userMomentDal(); var qr = (from x in usermdal.userMomentLST where x.mid == mid1 select x.username).ToArray(); List <Profile> allprofiles = (from x in pDal.profilesList select x).ToList <Profile>(); List <userMoments> AllUsers = (from x in usermdal.userMomentLST select x).ToList <userMoments>(); List <Profile> selected = new List <Profile>(); List <userMoments> usersinthisgroup = new List <userMoments>(); var size = qr.Count(); foreach (var z in AllUsers) { for (int v = 0; v < size; v++) { if (z.username == qr[v]) { usersinthisgroup.Add(z); } } } Session["UsersList"] = usersinthisgroup; foreach (var z in allprofiles) { for (int v = 0; v < size; v++) { if (z.username == qr[v]) { selected.Add(z); } } } Session["SelectedList"] = selected; return(View(selected)); }