public ActionResult ShowAllGroups() { momentsDal mDal = new momentsDal(); List <moments> result = (from x in mDal.momentsLst select x).ToList <moments>(); return(View("searchMoment", result)); }
public ActionResult PrivacyEditForm() { int newStatus = 0; var status = Request.Form["editprivacy"]; if (status != null) { newStatus = 1; } int mid2 = Convert.ToInt32(Session["correntMid"]); momentsDal md = new momentsDal(); List <moments> litsofallmd = (from tmp in md.momentsLst where tmp.mid.Equals(mid2) select tmp).ToList <moments>(); var toedit = md.momentsLst.Where(f => f.mid.Equals(mid2)).ToList(); toedit.ForEach(a => a.IsPublic = newStatus); md.SaveChanges(); if (newStatus == 1) { TempData["ErrorMessageEdit"] = "Your group will be appear in the searching"; } else { TempData["ErrorMessageEdit"] = "Your group will not appear in the searching"; } return(View("PrivacyEditForm")); }
public ActionResult EditGroupiIcon(IEnumerable <HttpPostedFileBase> imageModel) { byte[] data; int mid2 = Convert.ToInt32(Session["correntMid"]); using (Stream inputStram = Request.Files[0].InputStream) { MemoryStream memorystram = inputStram as MemoryStream; if (memorystram == null) { memorystram = new MemoryStream(); inputStram.CopyTo(memorystram); } data = memorystram.ToArray(); momentsDal md = new momentsDal(); List <moments> litsofallmd = (from tmp in md.momentsLst where tmp.mid.Equals(mid2) select tmp).ToList <moments>(); var toedit = md.momentsLst.Where(f => f.mid.Equals(mid2)).ToList(); toedit.ForEach(a => a.mImage = data); md.SaveChanges(); ViewData["photo"] = "Photo Added"; } return(RedirectToAction("UserMoments", "User")); }
public ActionResult searchMoment() { string text = Request.Form["text"]; momentsDal mDal = new momentsDal(); List <moments> result = (from x in mDal.momentsLst where x.mName.StartsWith(text) && x.IsPublic == 1 select x).ToList <moments>(); return(View(result)); }
public ActionResult RunCreateGroup(moments obj) { int counter; string MomentName = Request.Form["MomentName"].ToString(); string MomentDescription = Request.Form["MomentDescription"].ToString(); string getthemaxnumber = Request.Form["Momentmaxnumber"].ToString(); Session["getthemaxnumber"] = getthemaxnumber; var authToken = new byte[16]; byte[] Momentimage = authToken; userMomentDal usrmomentsdal = new userMomentDal(); momentsDal moments = new momentsDal(); List <moments> momentsID = (from tmp in moments.momentsLst select tmp).ToList <moments>(); if (momentsID.Count == 0) { counter = 1; } else { counter = moments.momentsLst.Max(x => x.mid) + 1; } moments added_moment = new moments(); added_moment.mid = 1; added_moment.mImage = Momentimage; added_moment.mName = MomentName; added_moment.mDescription = MomentDescription; moments.momentsLst.Add(added_moment); moments.SaveChanges(); users u = GetUser(); userMoments usermoment = new userMoments(); usermoment.username = u.username; Session["mid"] = counter; usermoment.mid = counter; usermoment.GroupName = MomentName; Session["MomentName1"] = MomentName; Session["getmidd"] = usermoment.mid; usermoment.uType = "Admin"; umd.userMomentLST.Add(usermoment); umd.SaveChanges(); return(View("AddMembersToGroup")); }
public static string getMomentTitle(string invitation) { List <string> splitted = invitation.Split(' ').ToList <string>(); momentsDal mDal = new momentsDal(); int mid = Convert.ToInt32(splitted[1]); List <moments> m = (from x in mDal.momentsLst where x.mid == mid select x).ToList <moments>(); if (m.Count > 0) { return(m[0].mName); } return("Error occured"); }
public static string getMomentName(string mid) { int id = int.Parse(mid); momentsDal dal = new momentsDal(); List <moments> m = (from x in dal.momentsLst where x.mid == id select x).ToList <moments>(); try { return(m[0].mName); }catch (Exception e) { return("Not Founded"); } }
public ActionResult joinAccepted() { string username = Request.Form["username"]; string uFrom = Request.Form["uFrom"]; int id = Convert.ToInt32(Request.Form["id"]); Notifications n = new Notifications(); notificationsDal nDal = new notificationsDal(); int size = (from x in nDal.nLst select x).ToList <Notifications>().Count() + 1; List <Notifications> tmp = (from x in nDal.nLst where x.id == id select x).ToList <Notifications>(); nDal.nLst.RemoveRange(nDal.nLst.Where(x => x.id == id)); nDal.SaveChanges(); tmp[0].status = "Accepted"; nDal.nLst.Add(tmp[0]); nDal.SaveChanges(); n.id = id; n.dateSent = DateTime.Now.Date; n.status = "Return Accepted"; n.type = tmp[0].type; n.uFrom = username; n.username = uFrom; nDal.nLst.Add(n); nDal.SaveChanges(); int mid = Convert.ToInt32((tmp[0].type.Split(' '))[1]); userMomentDal mDal = new userMomentDal(); userMoments uM = new userMoments(); momentsDal d = new momentsDal(); string groupName = (from x in d.momentsLst where x.mid == mid select x).ToList <moments>()[0].mName; int tableId = (from x in mDal.userMomentLST select x).ToList <userMoments>().Count() + 1; uM.id = tableId; uM.GroupName = groupName; uM.mid = mid; uM.uType = "User"; uM.username = uFrom; mDal.userMomentLST.Add(uM); mDal.SaveChanges(); return(RedirectToAction("showNotifications", "Notifications")); }
public ActionResult UserMoments() { classActive("momentsActive"); users corruser = new users(); corruser = GetUser(); userMomentDal dusernames = new userMomentDal(); momentsDal md = new momentsDal(); userMoments useromoentsobj = new userMoments(); momentsDal moments = new momentsDal(); List <userMoments> allmomentsusehave = (from tmp in dusernames.userMomentLST where corruser.username.Equals(tmp.username) select tmp).ToList <userMoments>(); return(View(allmomentsusehave)); }
void clear_data_from_database() { userMomentDal d = new userMomentDal(); momentsDal d1 = new momentsDal(); //usersDal user1 = new usersDal(); foreach (var entity in d.userMomentLST) { d.userMomentLST.Remove(entity); } d.SaveChanges(); foreach (var entity in d1.momentsLst) { d1.momentsLst.Remove(entity); } d1.SaveChanges(); //foreach (var entity in user1.userLst) // user1.userLst.Remove(entity); // user1.SaveChanges(); }
public ActionResult ExitGroup(int id, int mid1) { users corruser = new users(); corruser = GetUser(); userMomentDal usermdal = new userMomentDal(); momentsDal momentsmdal = new momentsDal(); var getifuserUser = usermdal.userMomentLST.Where(x => (corruser.username == x.username) && x.uType == "User" && id == x.id).SingleOrDefault(); var getifuseradmin = usermdal.userMomentLST.Where(x => (corruser.username == x.username) && x.uType == "Admin" && id == x.id).SingleOrDefault(); /* List<userMoments> allmomentsusehave = (from tmp in dusernames.userMomentLST * where corruser.username.Equals(tmp.username) * select tmp).ToList<userMoments>();*/ if (getifuseradmin != null) { List <userMoments> allmomentsusehave = (from tmp in usermdal.userMomentLST where id.Equals(tmp.mid) select tmp).ToList <userMoments>(); usermdal.userMomentLST.RemoveRange(usermdal.userMomentLST.Where(x => x.mid == mid1)); usermdal.SaveChanges(); momentsmdal.momentsLst.RemoveRange(momentsmdal.momentsLst.Where(x => x.mid == mid1)); momentsmdal.SaveChanges(); } else if (getifuserUser != null) { usermdal.userMomentLST.RemoveRange(usermdal.userMomentLST.Where(x => (x.mid == mid1) && (x.username == corruser.username))); usermdal.SaveChanges(); } return(RedirectToAction("UserMoments", "User")); }
public ActionResult EditGroupName() { var getgroupnewname = Request.Form["editgroupname"].ToString(); int mid2 = Convert.ToInt32(Session["correntMid"]); momentsDal md = new momentsDal(); userMomentDal umd = new userMomentDal(); List <moments> litsofallmd = (from tmp in md.momentsLst where tmp.mid.Equals(mid2) select tmp).ToList <moments>(); var toedit = md.momentsLst.Where(f => f.mid.Equals(mid2)).ToList(); if (litsofallmd.Count > 0) { if (litsofallmd[0].mName != getgroupnewname) { toedit.ForEach(a => a.mName = getgroupnewname); md.SaveChanges(); List <userMoments> membersofthisgroup = (from tmp in umd.userMomentLST where tmp.mid.Equals(mid2) select tmp).ToList <userMoments>(); foreach (var x in membersofthisgroup) { umd.userMomentLST.Remove(x); userMoments toadd1 = new userMoments(); toadd1.id = x.id; toadd1.GroupName = getgroupnewname; toadd1.mid = x.mid; toadd1.username = x.username; toadd1.uType = x.uType; umd.userMomentLST.Add(toadd1); umd.SaveChanges(); } TempData["ErrorMessageEdit"] = "Your Group Name Has Been Edited Sucessfully"; return(View("EditGroupName")); } } { TempData["ErrorMessageEdit"] = "You Have A Problem With Group Name , Please Enter New Name"; return(View("EditGroupName")); } }