Ejemplo n.º 1
0
        public ActionResult DeleteConfirmed(int id)
        {
            PatentModel patentmodel = db.PatentModels.Find(id);

            db.PatentModels.Remove(patentmodel);
            db.SaveChanges();
            return(RedirectToAction("MyPatent"));
        }
Ejemplo n.º 2
0
        [HttpPost]/*, ValidateAntiForgeryToken]*/
        public ActionResult PatentSave(PatentModel model)
        {
            if (ModelState.IsValid && SortMainObject.CheckUserHasWriteAccess(model.SortMainId))
            {
                model.Save();
            }

            return(null);
        }
Ejemplo n.º 3
0
 public ActionResult Edit(PatentModel patentmodel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(patentmodel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("MyPatent"));
     }
     return(View(patentmodel));
 }
Ejemplo n.º 4
0
        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"));
        }
Ejemplo n.º 5
0
        //
        // GET: /PatentModel/Details/5

        public ViewResult Details(int id)
        {
            PatentModel patentmodel = db.PatentModels.Find(id);

            patentmodel.ViewCount = patentmodel.ViewCount + 1;

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

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

            ViewBag.bookmarktag = false;
            // 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)
            {
                ViewBag.bookmarktag = true;
            }

            return(View(patentmodel));
        }
Ejemplo n.º 6
0
        //
        // GET: /PatentModel/Delete/5

        public ActionResult Delete(int id)
        {
            PatentModel patentmodel = db.PatentModels.Find(id);

            return(View(patentmodel));
        }
Ejemplo n.º 7
0
        public ActionResult Create(PatentModel patentmodel)
        {
            if (ModelState.IsValid)
            {
                string      name = Membership.GetUser().UserName;
                UserProfile user = db.UserProfiles.SingleOrDefault(p => p.UserName == name);
                patentmodel.UserProfile = user;
                user.Patent.Add(patentmodel);
                //db.PatentModels.Add(patentmodel);
                //Create an update for patents
                CreateUpdates("Published a new patent titled " + patentmodel.Title, "/PatentModel/Details/" + patentmodel.ID, 7, user.UserProfileId, patentmodel.Keyword);

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

                //Adding the Tag
                if (patentmodel.Keyword != null && patentmodel.Keyword != "")
                {
                    string keyword = patentmodel.Keyword;
                    //If written new tag
                    string[] Tags = keyword.Split(';');
                    foreach (string tagname in Tags)
                    {
                        string Trimtagname = tagname.Trim();
                        Tag    Item        = db.Tags.FirstOrDefault(p => p.TagName.ToLower() == Trimtagname.ToLower());
                        if (Item != null)
                        {
                            if (AddedTags.Contains(Item) != true && !(Item.Patents.Any(p => p.ID == patentmodel.ID)))
                            {
                                Item.TagLinkedItems += 1;
                                patentmodel.Tags.Add(Item);
                                Item.Patents.Add(patentmodel);
                                AddedTags.Add(Item);
                            }
                        }
                        else //If (Item == null)
                        {
                            //Create a New Tag
                            Tag NewItem = new Tag();
                            NewItem.TagName        = Trimtagname;
                            NewItem.TagLinkedItems = 1;
                            db.Tags.Add(NewItem);
                            patentmodel.Tags.Add(NewItem);
                            NewItem.Patents.Add(patentmodel);
                            AddedTags.Add(NewItem);
                        }
                    }
                }
                //-----------End of Adding Tags

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

                if (Sidebarnumber == 2)
                {
                    Sidebarnumber = 1;
                    return(RedirectToAction("Create", "Jobs", new { id = 2 }));
                }
                else
                {
                    return(RedirectToAction("MyPatent"));
                }
            }

            else
            {
                return(View(patentmodel));
            }
        }
Ejemplo n.º 8
0
        //
        // GET: /PatentModel/

        public ViewResult Index()
        {
            string name = Membership.GetUser().UserName;
            int    userID;
            string rankTag1 = "default";
            string rankTag2 = "default";
            string rankTag3 = "default";

            // Get all possible patents
            UserProfile user = db.UserProfiles.SingleOrDefault(p => p.UserName == name);

            userID = user.UserProfileId;

            List <Specialization> special = user.Specializations.ToList();

            for (int loop = 0; loop < special.Count(); loop++)
            {
                String temp = special[loop].SpecializationName.ToString();
                if (loop == 0)
                {
                    rankTag1 = temp;
                }
                else if (loop == 1)
                {
                    rankTag2 = temp;
                }
                else if (loop == 2)
                {
                    rankTag3 = temp;
                }
            }


            var result = from n in db.PatentModels
                         orderby n.ID
                         select n;

            // Make it into a list
            List <PatentModel> resultlist = new List <PatentModel>();

            resultlist = result.ToList();

            // Get max of ID
            if (resultlist.Count != 0)
            {
                int maxID = resultlist[resultlist.Count() - 1].ID;

                for (int i = 0; i <= maxID; i++)
                {
                    PatentModel patentmodel = db.PatentModels.Find(i);
                    // If there is a hit then
                    if (patentmodel != null)
                    {
                        // Initialise ranking
                        patentmodel.Ranking = 0;
                        if (patentmodel.Keyword.Contains(rankTag1))
                        {
                            patentmodel.Ranking = patentmodel.Ranking + 1;
                        }
                        if (patentmodel.Title.Contains(rankTag1))
                        {
                            patentmodel.Ranking = patentmodel.Ranking + 1;
                        }
                        if (patentmodel.About.Contains(rankTag1))
                        {
                            patentmodel.Ranking = patentmodel.Ranking + 1;
                        }
                        if (patentmodel.UserProfile.Specializations.ToString().Contains(rankTag1))
                        {
                            patentmodel.Ranking = patentmodel.Ranking + 1;
                        }
                        if (patentmodel.Keyword.Contains(rankTag2))
                        {
                            patentmodel.Ranking = patentmodel.Ranking + 1;
                        }
                        if (patentmodel.Title.Contains(rankTag2))
                        {
                            patentmodel.Ranking = patentmodel.Ranking + 1;
                        }
                        if (patentmodel.About.Contains(rankTag2))
                        {
                            patentmodel.Ranking = patentmodel.Ranking + 1;
                        }
                        if (patentmodel.UserProfile.Specializations.ToString().Contains(rankTag2))
                        {
                            patentmodel.Ranking = patentmodel.Ranking + 1;
                        }
                        if (patentmodel.Keyword.Contains(rankTag3))
                        {
                            patentmodel.Ranking = patentmodel.Ranking + 1;
                        }
                        if (patentmodel.Title.Contains(rankTag3))
                        {
                            patentmodel.Ranking = patentmodel.Ranking + 1;
                        }
                        if (patentmodel.About.Contains(rankTag3))
                        {
                            patentmodel.Ranking = patentmodel.Ranking + 1;
                        }
                        if (patentmodel.UserProfile.Specializations.ToString().Contains(rankTag3))
                        {
                            patentmodel.Ranking = patentmodel.Ranking + 1;
                        }
                        //Put entry in db
                        db.Entry(user).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                }
            }

            var finalresult = from n in db.PatentModels
                              orderby n.Ranking descending
                              select n;


            return(View(finalresult.ToList()));

            //return View(db.PatentModels.ToList());
        }