public ActionResult AddBookmark(string ID)
        {
            int id = Convert.ToInt16(ID);
            // Get the user name of the current logged in user
            string name = Membership.GetUser().UserName;
            // Get the entire userprofile associated with this user
            UserProfile user = db.UserProfiles.SingleOrDefault(p => p.UserName == name);

            // Check if a bookmark with these credentials exsists in the Db
            Bookmark bookmark = db.Bookmarks.SingleOrDefault(b => b.itemID == id && b.userID == user.UserProfileId && b.bookmarkType == "Patent");

            if (bookmark == null)
            {
                // No Bookmark exsists,  thereforre add this bookmark into the Db
                Bookmark tempBookmark = new Bookmark();
                tempBookmark.itemID = id;
                tempBookmark.bookmarkType = "Patent";
                tempBookmark.userID = user.UserProfileId;
                db.Bookmarks.Add(tempBookmark);
                db.SaveChanges();

                //Adding a notification item to the owner of the patent
                PatentModel patent = db.PatentModels.SingleOrDefault(b => b.ID == tempBookmark.itemID);
                UserProfile updateowner = db.UserProfiles.SingleOrDefault(p => p.UserProfileId == patent.UserProfile.UserProfileId);
                string patentDescription = patent.Title;
                Notification newnoti = new Notification
                {
                    message = user.FirstName + " bookmarked your patent : " + patentDescription,
                    link = "/Profile/Index/" + user.UserProfileId,
                    New = true,
                    imagelink = user.PhotoUrl,
                };

                updateowner.Notifications.Add(newnoti);
                db.Entry(updateowner).State = EntityState.Modified;
                db.SaveChanges();
            }

            return RedirectToAction("Index", "PublicationModel");
        }
        public void Follow(string username, string url)
        {
            string name = Membership.GetUser().UserName;
            myprofile = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == name);
            // UserProfile followerProfile = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == username);
            // UserProfile followerProfile = new UserProfile();

            Relationship tempR = new Relationship
            {
                personAName = name,
                personBName = username,
                tier = myprofile.Default //setting the default tier
            };

            followPeersDB.Relationships.Add(tempR);
            followPeersDB.SaveChanges();

            UserProfile personB = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == username);
            UserProfile follower = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == name);
            Notification newnoti = new Notification
            {
                message = follower.FirstName + " started following you.",
                link = "/Profile/Index/" + follower.UserProfileId,
                New = true,
                imagelink = myprofile.PhotoUrl,
            };

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

            Response.Redirect(url);
            // return RedirectToAction("Index", "Profile", new { id = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == username).UserProfileId });
        }
        public ActionResult AddComment(int commentid, string message, int redirect)
        {
            string name = Membership.GetUser().UserName;
            UserProfile myprofile = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == name);

            Update update = followPeersDB.Updates.SingleOrDefault(p => p.UpdateId == commentid);
            // UserProfile user = update.UserProfiles.ElementAt(0);
            //if (myprofile.UserProfileId != update.owner)
            if (myprofile.UserProfileId != update.UserProfiles.ElementAt(0).UserProfileId)
            {
                CreateUpdates(message, "/Notice/Index/" + myprofile.UserProfileId, 3, myprofile.UserProfileId);
                followPeersDB.Entry(myprofile).State = EntityState.Modified;
            }

            NoticeComment comment = new NoticeComment() { commenter = myprofile, message = message, time = DateTime.Now, update = update };
            followPeersDB.NoticeComments.Add(comment);

            followPeersDB.SaveChanges();

            //when adding a comment on a noticeboard, need to create a notification item also

            //notification items have to be created for
            // 1. owner of the update the comment is attached to (if owner is not the same as current commenter)
            // 2. commenters of other comments under the same update (if they are not the same as current commenter)
            // 3. owner of the noticeboard (if owner is not the same as current commenter)

            List<UserProfile> notiaddedlist = new List<UserProfile>();
            //Case 1 owner of the update
            if (update.owner != myprofile.UserProfileId)
            {
                UserProfile updateowner = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserProfileId == update.owner);
                UserProfile user = update.UserProfiles.ElementAt(0);
                Notification newnoti = new Notification
                {
                    message = myprofile.FirstName + " commented on your post : " + message,
                    link = "/Notice/Index/" + user.UserProfileId,
                    New = true,
                    imagelink = myprofile.PhotoUrl,
                };
                var toadd = true;
                //to prevent adding notifications to the same person twice
                foreach (var item in notiaddedlist)
                {
                    if (item == updateowner) toadd = false;
                }
                if (toadd == true)
                {
                    notiaddedlist.Add(updateowner);
                    updateowner.Notifications.Add(newnoti);
                    followPeersDB.Entry(updateowner).State = EntityState.Modified;
                    followPeersDB.SaveChanges();
                }
            }

            //Case 2. commenters of other comments under the same update (if they are not the same as current commenter OR the noticeboard owner)
            IEnumerable<NoticeComment> result = from n in followPeersDB.NoticeComments
                                                where n.update.UpdateId == update.UpdateId
                                                select n;
            int noticeownerid = update.UserProfiles.ElementAt(0).UserProfileId;
            foreach (var n in result)
            {
                if ((n.commenterId != myprofile.UserProfileId) && (n.commenterId != noticeownerid))
                {
                    UserProfile commenter = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserProfileId == n.commenterId);
                    UserProfile user = update.UserProfiles.ElementAt(0);
                    Notification newnoti = new Notification
                    {
                        message = myprofile.FirstName + " commented on your post : " + message,
                        link = "/Notice/Index/" + user.UserProfileId,
                        New = true,
                        imagelink = myprofile.PhotoUrl,
                    };
                    var toadd = true;
                    //to prevent adding notifications to the same person twice
                    foreach (var item in notiaddedlist)
                    {
                        if (item == commenter) toadd = false;
                    }
                    if (toadd == true)
                    {
                        notiaddedlist.Add(commenter);
                        commenter.Notifications.Add(newnoti);
                        followPeersDB.Entry(commenter).State = EntityState.Modified;
                        followPeersDB.SaveChanges();
                    }
                }
            }
            //Case 3. owner of the noticeboard (if owner is not the same as current commenter)
            if (noticeownerid != myprofile.UserProfileId)
            {

                UserProfile noticeowner = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserProfileId == noticeownerid);
                Notification newnoti = new Notification
                {
                    message = myprofile.FirstName + " commented on your Noticeboard : " + message,
                    link = "/Notice/Index/" + noticeownerid,
                    New = true,
                    imagelink = myprofile.PhotoUrl,
                };
                var toadd = true;
                //to prevent adding notifications to the same person twice
                foreach (var item in notiaddedlist)
                {
                    if (item == noticeowner) toadd = false;
                }
                if (toadd == true)
                {
                    notiaddedlist.Add(noticeowner);
                    noticeowner.Notifications.Add(newnoti);
                    followPeersDB.Entry(noticeowner).State = EntityState.Modified;
                    followPeersDB.SaveChanges();
                }
            }

            return RedirectToAction("Index", "Notice", new { id = redirect });
        }
        public void Bookmark(string jobid, string url)
        {
            string name = Membership.GetUser().UserName;
            myprofile = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == name);
            int jobidINT = Convert.ToInt16(jobid);
            // UserProfile followerProfile = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == username);
            // UserProfile followerProfile = new UserProfile();
            Job job = followPeersDB.Jobs.SingleOrDefault(p => p.JobId == jobidINT);
            myprofile.Jobs.Add(job);
            followPeersDB.SaveChanges();

            UserProfile updateowner = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserProfileId == job.ownerId);
            string jobdescription = job.Description;
            if (jobdescription.Length > 60) jobdescription = job.Description.Substring(0, 60) + "...";
            Notification newnoti = new Notification
            {
                message = myprofile.FirstName + " bookmarked your job post : " + jobdescription,
                link = "/Profile/Index/" + myprofile.UserProfileId,
                New = true,
                imagelink = myprofile.PhotoUrl,
            };

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

            Response.Redirect(url);
            // return RedirectToAction("Index", "Profile", new { id = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == username).UserProfileId });
        }
        public ActionResult PosttoNoticeBoard(string message, string redirect)
        {
            string name = Membership.GetUser().UserName;
            UserProfile userprofile = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == name);
            // userprofile.StatusMessage = message;
            int id = Convert.ToInt16(redirect);
            CreateUpdates(message, "/Notice/Index/" + id, 5, id);
            followPeersDB.Entry(userprofile).State = EntityState.Modified;
            followPeersDB.SaveChanges();

            UserProfile Noticeowner = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserProfileId == id);
            if (message.Length > 30) message = message.Substring(0, 25) + "...";

            Notification newnoti = new Notification
            {
                message = userprofile.FirstName + " wrote on your Noticeboard : " + message,
                link = "/Notice/Index/" + id,
                New = true,
                imagelink = userprofile.PhotoUrl,
            };
            Noticeowner.Notifications.Add(newnoti);
            followPeersDB.Entry(Noticeowner).State = EntityState.Modified;
            followPeersDB.SaveChanges();

            return RedirectToAction("Index", "Notice", new { id = id });
        }
Beispiel #6
0
        public ActionResult AddEvent(Event model, string[] InvitesId)
        {
            if (model.EventName == null)
                {
                    model.EventName = "default";
                }
                if (model.EventDate == DateTime.MinValue)
                {
                    model.EventDate = DateTime.Now;
                }
                if (model.EventTime == DateTime.MinValue)
                {
                    model.EventTime = DateTime.Now;
                }
                if (model.EventDesc == null)
                {
                    model.EventDesc = "default";
                }

                /*
                //Adding Tags
                //To keep track of tags being added
                List<Tag> AddedTags = new List<Tag>();

                //Adding the Tag
                if (model.EventDesc!= null)
                {
                    string EventDescTags = model.EventDesc.ToString();
                    //If written new tag
                    string[] Tags = EventDescTags.Split(' ');
                    foreach (string tagname in Tags)
                    {
                        string Trimtagname = tagname.Trim();
                        Tag Item = followPeersDB.Tags.FirstOrDefault(p => p.TagName.ToLower() == Trimtagname.ToLower());
                        if (Item != null)
                        {
                            if (AddedTags.Contains(Item) != true && !(Item.Events.Any(p => p.EventId == model.EventId)))
                            {
                                Item.TagLinkedItems += 1;
                                model.Tags.Add(Item);
                                Item.Events.Add(model);
                                AddedTags.Add(Item);
                            }
                        }
                        else //If (Item == null)
                        {
                            //Create a New Tag
                            Tag NewItem = new Tag();
                            NewItem.TagName = Trimtagname;
                            NewItem.TagLinkedItems = 1;
                            followPeersDB.Tags.Add(NewItem);
                            model.Tags.Add(NewItem);
                            NewItem.Events.Add(model);
                            AddedTags.Add(NewItem);
                        }
                    }
                }
                //-----------End of Adding Tags*/

                string name = Membership.GetUser().UserName;
                UserProfile user = db.UserProfiles.SingleOrDefault(p => p.UserName == name);

                //Adding event for User (Creator of Event) and Adding User to Event
                user.Events.Add(model);
                model.Invitees.Add(user);

                //Adding event for All invitees and all invitees to event
                if (InvitesId != null)
                {
                    foreach (var InviteeId in InvitesId)
                    {
                        if (InviteeId != null && InviteeId != "")
                        {
                            int id = Convert.ToInt32(InviteeId);
                            UserProfile invitee = db.UserProfiles.SingleOrDefault(p => p.UserProfileId == id);

                            try
                            {
                                if (user.UserProfileId != id)
                                {
                                    invitee.Events.Add(model);
                                    model.Invitees.Add(invitee);

                                    //For Notifications
                                    string makeMessage = user.FirstName + " invited you to an event : '" + model.EventName+"'";
                                    int eventnumber = followPeersDB.Events.Count() + 1;
                                    Notification newnoti = new Notification
                                    {
                                        message = makeMessage,
                                        link = "/Event/EventDetail/" + eventnumber,
                                        New = true,
                                    };

                                    invitee.Notifications.Add(newnoti);
                                }

                            }
                            catch
                            {
                            }
                        }
                    }
                }

                //Add event to database
                db.Events.Add(model);

                db.Entry(user).State = EntityState.Modified;
                db.SaveChanges();

                //Calculating Event Id to Create Notification
                int EventId = followPeersDB.Events.Count();

                //If Event was created, we find it and create a notification
                CategoryPost post = new CategoryPost
                {
                    TimeStamp = DateTime.Now,
                    PostMessage = "Created a new Event titled " + model.EventName,
                    Type = 3,
                    Postedby = user.UserProfileId,
                    Category = model.EventDesc,
                    Link = "/Event/EventDetail/" + EventId,
                };
                user.CategoryPosts.Add(post);

                db.Entry(user).State = EntityState.Modified;
                db.SaveChanges();

                return RedirectToAction("Index");
        }
        public ActionResult Recommend(int id, string NameId)
        {
            UserProfile user = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == name);
            Bookmark model = new Bookmark();

            if (NameId != null && NameId != "")
            {
                int recommendid = Convert.ToInt32(NameId);
                UserProfile invitee = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserProfileId == recommendid);

                try
                {
                    if (user.UserProfileId != recommendid)
                    {
                        model.bookmarkType = "Publication";
                        model.itemID = id;
                        model.userID = recommendid;
                        followPeersDB.Bookmarks.Add(model);
                        followPeersDB.SaveChanges();

                        //Adding a notification item to the recommended person
                        PublicationModel book = followPeersDB.PublicationModels.SingleOrDefault(b => b.publicationID == id);
                        Notification newnoti = new Notification
                        {
                            message = user.FirstName + user.LastName + " has recommeded you a publication : " + book.title,
                            link = "/PublicationModel/Details/" + id,
                            New = true,
                            imagelink = user.PhotoUrl,
                        };

                        invitee.Notifications.Add(newnoti);
                        followPeersDB.Entry(invitee).State = EntityState.Modified;
                        followPeersDB.SaveChanges();
                    }

                }
                catch
                {
                }
            }
            string result = "#";
            return Json(result);
        }
        public ActionResult Save(int jobid)
        {
            string name = Membership.GetUser().UserName;
            myprofile = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == name);
            int jobidINT = Convert.ToInt16(jobid);
            // UserProfile followerProfile = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == username);
            // UserProfile followerProfile = new UserProfile();
            Jobs job = followPeersDB.Jobs.SingleOrDefault(p => p.JobId == jobidINT);
            myprofile.Jobs.Add(job);
            followPeersDB.SaveChanges();

            UserProfile updateowner = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserProfileId == job.ownerID);
            string jobtitle = job.Title;
            Notification newnoti = new Notification
            {
                message = myprofile.FirstName + " Applied to your job post : " + jobtitle,
                link = "/Profile/Index/" + myprofile.UserProfileId,
                New = true,
                imagelink = myprofile.PhotoUrl,
            };

            updateowner.Notifications.Add(newnoti);
            followPeersDB.Entry(updateowner).State = EntityState.Modified;
            followPeersDB.SaveChanges();
            return View();
        }
Beispiel #9
0
        //
        // GET: /Default1/
        public ActionResult AppliedGroup(int id)
        {
            string name = Membership.GetUser().UserName;
            myprofile = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == name);
            // UserProfile followerProfile = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == username);
            // UserProfile followerProfile = new UserProfile();
            Group group = followPeersDB.Groups.SingleOrDefault(p => p.GroupId == id);
            bool x = false;
            if (group.Members.Contains(myprofile) && myprofile.Groups.Contains(group))
            {
                group.Members.Remove(myprofile);
                myprofile.Groups.Remove(group);
                followPeersDB.SaveChanges();

                x = true;
            }
            else
            {
                group.Members.Add(myprofile);
                myprofile.Groups.Add(group);
                followPeersDB.SaveChanges();
            }

            UserProfile updateowner = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserProfileId == group.OwnerId);
            string grouptitle = group.Name;
            string makeMessage = "";
            if (x == false)
                makeMessage = myprofile.FirstName + " Joined group : " + grouptitle;
            else
                makeMessage = myprofile.FirstName + " UnJoined group : " + grouptitle;

            Notification newnoti = new Notification
            {
                message = makeMessage,
                link = "/Profile/Index/" + myprofile.UserProfileId,
                New = true,
                imagelink = myprofile.PhotoUrl,
            };

            updateowner.Notifications.Add(newnoti);
            followPeersDB.Entry(updateowner).State = EntityState.Modified;
            followPeersDB.SaveChanges();
            return RedirectToAction("Index");
        }
Beispiel #10
0
        //
        // GET: /Default1/
        public ActionResult AppliedJob(int id)
        {
            myprofile = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == name);
            // UserProfile followerProfile = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == username);
            // UserProfile followerProfile = new UserProfile();
            Jobs job = followPeersDB.Jobs.SingleOrDefault(p => p.JobId == id);
            myprofile.AppliedJobs.Add(job);
            followPeersDB.SaveChanges();

            UserProfile updateowner = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserProfileId == job.ownerID);
            string jobtitle = job.Title;
            Notification newnoti = new Notification
            {
                message = myprofile.FirstName + " Applied to your job post : " + jobtitle,
                link = "/Profile/Index/" + myprofile.UserProfileId,
                New = true,
                imagelink = myprofile.PhotoUrl,
            };

            updateowner.Notifications.Add(newnoti);
            followPeersDB.Entry(updateowner).State = EntityState.Modified;
            followPeersDB.SaveChanges();
            return RedirectToAction("Index");
        }
Beispiel #11
0
        public ActionResult PosttoNoticeBoard(string message, string redirect, bool Ischecked = false)
        {
            string name = Membership.GetUser().UserName;
            UserProfile userprofile = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == name);
            // userprofile.StatusMessage = message;
            int id = Convert.ToInt16(redirect);
            // bool checkvalue = bool.Parse(Request.Form.GetValues("Ischecked")[0]);
            if (Ischecked == true)
            {
                int i = 0;
                List<FollowPeers.Models.Relationship> followednames = followPeersDB.Relationships.Where(p => p.personAName == name).ToList();
                List<FollowPeers.Models.UserProfile> followedpeers = followPeersDB.UserProfiles.Where(p => p.UserProfileId < 0).ToList(); // null list
                foreach (var peername in followednames)
                {

                    followedpeers.Add(followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == peername.personBName));
                    if (followedpeers.Count() > 0)
                    {
                        CreateUpdates(message, "/Notice/Index/" + followedpeers[i].UserProfileId, 9, followedpeers[i].UserProfileId);

                        /*  UserProfile Noticeowner = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserProfileId == id);
                          if (message.Length > 30) message = message.Substring(0, 25) + "...";

                          Notification newnoti = new Notification
                          {
                              message = userprofile.FirstName + " wrote on your Noticeboard : " + message,
                              link = "/Notice/Index/" + id,
                              New = true,
                              imagelink = userprofile.PhotoUrl,
                          };
                          Noticeowner.Notifications.Add(newnoti);
                          followPeersDB.Entry(Noticeowner).State = EntityState.Modified;
                          followPeersDB.SaveChanges();*/

                    }
                    i++;
                    followPeersDB.Entry(userprofile).State = EntityState.Modified;
                    followPeersDB.SaveChanges();
                }

                foreach (var peer in followedpeers)
                {
                    UserProfile Noticeowner = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserProfileId == peer.UserProfileId);
                    if (message.Length > 30) message = message.Substring(0, 25) + "...";

                    Notification newnoti = new Notification
                    {
                        message = userprofile.FirstName + " wrote on your Noticeboard : " + message,
                        link = "/Notice/Index/" + peer.UserProfileId,
                        New = true,
                        imagelink = userprofile.PhotoUrl,
                    };
                    Noticeowner.Notifications.Add(newnoti);
                    followPeersDB.Entry(Noticeowner).State = EntityState.Modified;
                    followPeersDB.SaveChanges();
                }

            }
            else
            {
                CreateUpdates(message, "/Notice/Index/" + id, 5, id);

                followPeersDB.Entry(userprofile).State = EntityState.Modified;
                followPeersDB.SaveChanges();

                UserProfile Noticeowner = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserProfileId == id);
                if (message.Length > 30) message = message.Substring(0, 25) + "...";

                Notification newnoti = new Notification
                {
                    message = userprofile.FirstName + " wrote on your Noticeboard : " + message,
                    link = "/Notice/Index/" + id,
                    New = true,
                    imagelink = userprofile.PhotoUrl,
                };
                Noticeowner.Notifications.Add(newnoti);
                followPeersDB.Entry(Noticeowner).State = EntityState.Modified;
                followPeersDB.SaveChanges();
            }

            return RedirectToAction("Index", "Notice", new { id = id });
        }
Beispiel #12
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);
        }