public ActionResult Create(PublicationModel publicationmodel, string[] keywordsId, string keyword)
        {
            if (ModelState.IsValid)
            {
                if (publicationmodel.author == null)
                {
                    publicationmodel.author = "default";
                }
                if (publicationmodel.conference == null)
                {
                    publicationmodel.conference = "default";
                }
                if (publicationmodel.description == null)
                {
                    publicationmodel.description = "default";
                }
                if (publicationmodel.issue == null)
                {
                    publicationmodel.issue = "default";
                }
                if (publicationmodel.journal == null)
                {
                    publicationmodel.journal = "default";
                }
                if (publicationmodel.keyword == null)
                {
                    publicationmodel.keyword = "default";
                }
                if (publicationmodel.page == null)
                {
                    publicationmodel.page = "default";
                }
                if (publicationmodel.publisher == null)
                {
                    publicationmodel.publisher = "default";
                }
                if (publicationmodel.referenceID == null)
                {
                    publicationmodel.referenceID = "Singapore";
                }
                if (publicationmodel.status == null)
                {
                    publicationmodel.status = "default";
                }
                if (publicationmodel.title == null)
                {
                    publicationmodel.title = "default";
                }
                if (publicationmodel.type == null)
                {
                    publicationmodel.type = "default";
                }
                if (publicationmodel.university == null)
                {
                    publicationmodel.university = "default";
                }
                if (publicationmodel.volume == null)
                {
                    publicationmodel.volume = "default";
                }
                if (publicationmodel.year == null)
                {
                    publicationmodel.year = 2012;
                }
                if (publicationmodel.viewCount == 0)
                {
                    publicationmodel.viewCount = 0;
                }
                if (publicationmodel.specialisation == null)
                {
                    publicationmodel.specialisation = "Physics";
                }
                publicationmodel.timestamp = DateTime.Now.ToString();
                if (Pubfilename != "")
                {
                    publicationmodel.filename = Pubfilename;
                    Pubfilename = "";
                }
                if (Imagename != "")
                {
                    publicationmodel.imagename = Imagename;
                    Imagename = "";
                }

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

                //Adding the Tag
                if (keywordsId != null)
                {
                    //Selected Existing Tags
                    foreach (string tag in keywordsId)
                    {
                        int TagId = Convert.ToInt32(tag);
                        Tag Item = followPeersDB.Tags.FirstOrDefault(p => p.TagId == TagId);
                        if (Item != null && !(Item.Publications.Any(p => p.publicationID == publicationmodel.publicationID)))
                        {
                            AddedTags.Add(Item);
                            //When Tag Linked to Item, incremented to keep count
                            Item.TagLinkedItems += 1;
                            publicationmodel.Tags.Add(Item);
                            Item.Publications.Add(publicationmodel);
                        }
                    }
                }
                if (keyword != null)
                {
                    //If written new tag
                    string[] Tags = keyword.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.Publications.Any(p => p.publicationID == publicationmodel.publicationID)))
                            {
                                Item.TagLinkedItems += 1;
                                publicationmodel.Tags.Add(Item);
                                Item.Publications.Add(publicationmodel);
                                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);
                            publicationmodel.Tags.Add(NewItem);
                            NewItem.Publications.Add(publicationmodel);
                            AddedTags.Add(NewItem);
                        }
                    }
                }
                //-----------End of Adding Tags

                string name = Membership.GetUser().UserName;
                UserProfile user = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == name);
                publicationmodel.UserProfile = user;
                user.Publication.Add(publicationmodel);

                int publicationmodelid = followPeersDB.PublicationModels.Count() + 1;

                CreateUpdates("Published a new publication titled " + publicationmodel.title, "/PublicationModel/Details/" + publicationmodelid, 6, user.UserProfileId, publicationmodel.keyword);

                //followPeersDB.PublicationModels.Add(publicationmodel);
                followPeersDB.Entry(user).State = EntityState.Modified;
                followPeersDB.SaveChanges();
                if (Sidebarnumber == 2)
                {
                    Sidebarnumber = 1;
                    return RedirectToAction("Create", "PatentModel", new { id = 2 });
                }
                return RedirectToAction("Index");
            }

            return View(publicationmodel);
        }
 public ActionResult Edit(PublicationModel publicationmodel)
 {
     if (ModelState.IsValid)
     {
         followPeersDB.Entry(publicationmodel).State = EntityState.Modified;
         followPeersDB.SaveChanges();
         return RedirectToAction("MyPublication");
     }
     return View(publicationmodel);
 }
        public ActionResult Create(PublicationModel publicationmodel)
        {
            if (ModelState.IsValid)
            {
                if (publicationmodel.author == null)
                {
                    publicationmodel.author = "default";
                }
                if (publicationmodel.conference == null)
                {
                    publicationmodel.conference = "default";
                }
                if (publicationmodel.description == null)
                {
                    publicationmodel.description = "default";
                }
                if (publicationmodel.issue == null)
                {
                    publicationmodel.issue = "default";
                }
                if (publicationmodel.journal == null)
                {
                    publicationmodel.journal = "default";
                }
                if (publicationmodel.keyword == null)
                {
                    publicationmodel.keyword = "default";
                }
                if (publicationmodel.page == null)
                {
                    publicationmodel.page = "default";
                }
                if (publicationmodel.publisher == null)
                {
                    publicationmodel.publisher = "default";
                }
                if (publicationmodel.referenceID == null)
                {
                    publicationmodel.referenceID = "Singapore";
                }
                if (publicationmodel.status == null)
                {
                    publicationmodel.status = "default";
                }
                if (publicationmodel.title == null)
                {
                    publicationmodel.title = "default";
                }
                if (publicationmodel.type == null)
                {
                    publicationmodel.type = "default";
                }
                if (publicationmodel.university == null)
                {
                    publicationmodel.university = "default";
                }
                if (publicationmodel.volume == null)
                {
                    publicationmodel.volume = "default";
                }
                if (publicationmodel.year == null)
                {
                    publicationmodel.year = 2012;
                }
                if (publicationmodel.viewCount == 0)
                {
                    publicationmodel.viewCount = 0;
                }
                if (publicationmodel.specialisation == null)
                {
                    publicationmodel.specialisation = "Physics";
                }
                publicationmodel.timestamp = DateTime.Now.ToString();

                string name = Membership.GetUser().UserName;
                UserProfile user = followPeersDB.UserProfiles.SingleOrDefault(p => p.UserName == name);
                publicationmodel.UserProfile = user;
                user.Publication.Add(publicationmodel);

                int publicationmodelid = followPeersDB.PublicationModels.Count() + 1;
                CreateUpdates("Published a new publication titled " + publicationmodel.title, "/PublicationModel/Details/" + publicationmodelid, 6, user.UserProfileId);

                //followPeersDB.PublicationModels.Add(publicationmodel);
                followPeersDB.Entry(user).State = EntityState.Modified;
                followPeersDB.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(publicationmodel);
        }