Ejemplo n.º 1
0
        public void CreateUpdates(string message, string link, int type, int id)
        {
            string myname = Membership.GetUser().UserName;
            UserProfile userprofile = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserProfileId == id);
            UserProfile myprofile = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == myname);
            Update record = new Update
            {
                Time = DateTime.Now,
                message = message,
                link = link,
                New = true,
                Own = true,
                type = type,
                owner = myprofile.UserProfileId
            };

            userprofile.Updates.Add(record); //add own update record

            string name = userprofile.UserName;
            IQueryable<string> custQuery = from cust in followPeersDB.Relationships where cust.personBName == name select cust.personAName;

            foreach (string personAname in custQuery)
            {
                Update record2 = new Update
                {
                    Time = DateTime.Now,
                    message = message,
                    link = link,
                    New = true,
                    Own = false,
                    type = type,
                    owner = userprofile.UserProfileId
                };

                UserProfile tempuserprofile = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == personAname);

                tempuserprofile.Updates.Add(record2);
            } //add a new update record for the followers
        }
Ejemplo n.º 2
0
        //
        // POST: /PatentModel/Create
        public void CreateUpdates(string message, string link, int type, int id, string category)
        {
            string myname = Membership.GetUser().UserName;
            UserProfile userprofile = db.UserProfiles.SingleOrDefault(p => p.UserProfileId == id);
            UserProfile myprofile = db.UserProfiles.SingleOrDefault(p => p.UserName == myname);
            Update record = new Update
            {
                Time = DateTime.Now,
                message = message,
                link = link,
                New = true,
                Own = true,
                type = type,
                owner = myprofile.UserProfileId
            };

            userprofile.Updates.Add(record); //add own update record

            if (category != null)
            {
                CategoryPost post = new CategoryPost
                    {
                        TimeStamp = DateTime.Now,
                        PostMessage = message,
                        Link = link,
                        Type = 5,
                        Postedby = myprofile.UserProfileId,
                        Category = category,
                    };

                userprofile.CategoryPosts.Add(post);
            }

            string name = userprofile.UserName;
            IQueryable<string> custQuery = from cust in db.Relationships where cust.personBName == name select cust.personAName;

            foreach (string personAname in custQuery)
            {
                Update record2 = new Update
                {
                    Time = DateTime.Now,
                    message = message,
                    link = link,
                    New = true,
                    Own = false,
                    type = type,
                    owner = userprofile.UserProfileId
                };

                UserProfile tempuserprofile = db.UserProfiles.SingleOrDefault(p => p.UserName == personAname);

                tempuserprofile.Updates.Add(record2);
            } //add a new update record for the followers
        }
Ejemplo n.º 3
0
        public ActionResult RecentUpdates(Update update, UserProfile profile)
        {
            var peerupdate = (from p in db.Updates where p.owner!= 1 select p);

            return View(peerupdate);
        }
Ejemplo n.º 4
0
        public void CreateUpdates(Course model, string category)
        {
            string name = Membership.GetUser().UserName;
            myprofile = db.UserProfiles.SingleOrDefault(p => p.UserName == name);
            string CreateMessage = "New Course Created titled '" + model.CourseName + "'";
            int coursenumber = db.Courses.Count() + 1;
            if (category != null)
            {
                if(category.Contains(';'))
                {
                    string[] Tagnames = category.Split(';');
                    CategoryPost post = new CategoryPost
                    {

                        TimeStamp = DateTime.Now,
                        PostMessage = CreateMessage,
                        Link = "/Course/Details/" + coursenumber,
                        Type = 4,
                        Postedby = myprofile.UserProfileId,
                        Category = Tagnames[0],
                    };

                    myprofile.CategoryPosts.Add(post);
                }
            }

            //For own updates
            Update record = new Update
            {
                Time = DateTime.Now,
                message = CreateMessage,
                link = "/Course/Details/" + coursenumber,
                New = true,
                Own = true,
                type = 6,
                owner = myprofile.UserProfileId
            };

            myprofile.Updates.Add(record); //add own update record

            db.Entry(myprofile).State = EntityState.Modified;
            db.SaveChanges();
        }
Ejemplo n.º 5
0
        public void like(string username, int achievementid, string url)
        {
            string name = Membership.GetUser().UserName;
            myprofile = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == name);
            UserProfile liked = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == username);
            UserProfile likedby = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == name);
            Achievement ach = followPeersDB.Achievements.SingleOrDefault(p => p.AchievementId == achievementid);
            if ((followPeersDB.AchievementLikes.Where(p => p.AchievementId == achievementid && p.UserProfileId == likedby.UserProfileId).ToList().Count() == 0))
            {

                ach.like++;
                followPeersDB.Entry(ach).State = EntityState.Modified;

                AchievementLike achlike = new AchievementLike
                {
                    UserProfileId = likedby.UserProfileId,
                    AchievementId = ach.AchievementId,
                    UserProfile = likedby

                };
                followPeersDB.Entry(achlike).State = EntityState.Added;
                Notification newnoti = new Notification
                {
                    message = likedby.FirstName + " liked your achievement titled" + ach.Title,
                    link = "/Profile/Index/" + likedby.UserProfileId,
                    New = true,
                    imagelink = likedby.PhotoUrl,
                };

                liked.Notifications.Add(newnoti);
                followPeersDB.Entry(liked).State = EntityState.Modified;

                Update newupdate = new Update
                {

                    New = true,
                    Own = true,
                    Time = System.DateTime.Now,
                    message = @liked.FirstName + "," + @ach.Title,
                    link = "/Profile/Index/" + liked.UserProfileId,
                    owner = likedby.UserProfileId,
                    type = 10 // achievement like
                };

                liked.Updates.Add(newupdate);
                followPeersDB.Entry(liked).State = EntityState.Modified;

                followPeersDB.SaveChanges();

            }
            else
            {
                ach.like--;
                followPeersDB.Entry(ach).State = EntityState.Modified;
                followPeersDB.SaveChanges();
                followPeersDB.AchievementLikes.Remove(followPeersDB.AchievementLikes.SingleOrDefault(p => p.AchievementId == achievementid && p.UserProfileId == likedby.UserProfileId));
                followPeersDB.SaveChanges();
            }

            Response.Redirect(url);
        }