public ActionResult Promotion_to_admin(int mid2, int id) { userMomentDal usermdal = new userMomentDal(); List <userMoments> usersiwant = (from x in usermdal.userMomentLST where (x.mid.Equals(mid2) && x.id.Equals(id)) select x).ToList <userMoments>(); if (usersiwant.Count() > 0) { userMoments useriwant1 = usersiwant[0]; usermdal.userMomentLST.RemoveRange(usermdal.userMomentLST.Where(x => x.mid == useriwant1.mid && x.id == useriwant1.id)); usermdal.SaveChanges(); userMoments newuser = new userMoments(); newuser.GroupName = useriwant1.GroupName; newuser.id = useriwant1.id; newuser.image = useriwant1.image; newuser.IsPublic = useriwant1.IsPublic; newuser.mid = useriwant1.mid; newuser.username = useriwant1.username; newuser.uType = "Admin"; usermdal.userMomentLST.Add(newuser); usermdal.SaveChanges(); } else { TempData["ErrorFound"] = "Cannot Found User"; } return(View("UserMainPage")); }
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 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)); }
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")); } }