public ActionResult CreateGroup(string name, string[] members)
        {
            string myname = Membership.GetUser().UserName;
            myprofile = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == myname);
            Group grp = new Group
            {
                Name = name,
                OwnerId = myprofile.UserProfileId,
                Members = new List<UserProfile>()
            };
            if (members == null || members.Count() == 0) return RedirectToAction("Index", "Bulletin", new { sort = 3 });
            for (int i = 0; i < members.Count(); i++)
            {
                string tempstr = members[i];

                IQueryable<UserProfile> custQuery = from cust in followPeersDB.UserProfiles where cust.FirstName + " " + cust.LastName == tempstr select cust;
                foreach (var profile in custQuery)
                {
                    grp.Members.Add(profile);
                }

            }
            followPeersDB.Groups.Add(grp);
            followPeersDB.SaveChanges();
            return RedirectToAction("Index", "Bulletin", new { sort = 3 });
        }
Beispiel #2
0
        public void CreateUpdates(Group model, string category)
        {
            if (category != null)
            {
                string GroupOwner = Membership.GetUser().UserName;
                myprofile = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == GroupOwner);
                CategoryPost post = new CategoryPost
                {
                    TimeStamp = DateTime.Now,
                    PostMessage = "New Group Has Recently Been Created titled" + model.Name,
                    Link = "/Groups/Details/"+model.GroupId,
                    Type = 2,
                    Postedby = myprofile.UserProfileId,
                    Category = category,
                };

                myprofile.CategoryPosts.Add(post);
            }
        }
Beispiel #3
0
 public ActionResult Edit(Group groupmodel)
 {
     if (ModelState.IsValid)
     {
         followPeersDB.Entry(groupmodel).State = EntityState.Modified;
         followPeersDB.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(groupmodel);
 }
Beispiel #4
0
        public ActionResult Create(Group groupmodel)
        {
            if (ModelState.IsValid)
            {
                string name = Membership.GetUser().UserName;
                UserProfile user = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == name);
                /*if (jobmodel.Enddate == null)
                {
                    jobmodel.Enddate = DateTime.Now;
                }
                if (jobmodel.publishDate == null)
                {
                    jobmodel.publishDate = DateTime.Now;
                }
                 */

                groupmodel.OwnerId = user.UserProfileId;

                int groupid = followPeersDB.Groups.Count() + 1;
                user.Groups.Add(groupmodel);
                //CreateUpdates("Published a new job titled " + groupmodel.Title, "/PublicationModel/Details/" + groupid, 6, user.UserProfileId);
                //followPeersDB.Entry(user).State = EntityState.Modified;
                CreateUpdates(groupmodel, groupmodel.GroupDesc);
                followPeersDB.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(groupmodel);
        }