コード例 #1
0
        public Hashtag GetOrCreateHashtag(string Tag,
                                          IMicroblog microblog)
        {
            lock (this)
            {
                string normalisedTagName = NormaliseTag(Tag);
                Hashtag tag;
                if (_hashtable.ContainsKey(normalisedTagName))
                {
                    tag = (Hashtag) _hashtable[normalisedTagName];

                    tag.AddSource(microblog);
                    tag.Seen();
                    return tag;
                }

                tag = new Hashtag(Tag,
                                  microblog);

                _hashtable.Add(normalisedTagName,
                               tag);
                Hashtags.Add(tag);
                return tag;
            }
        }
コード例 #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Hashtag hashtag = db.Hashtag.Find(id);

            db.Hashtag.Remove(hashtag);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #3
0
        public void Delete(Hashtag entity)
        {
            var data = this.hashtags.ToList();

            data.Remove(entity);

            this.hashtags = data.AsQueryable();
        }
コード例 #4
0
        public void Test_Hashtag_Insert()
        {
            var newTag = new Hashtag("Mock Tag", poi, user);

            this.repository.Insert(newTag);

            Assert.AreEqual(5, repository.Count());
        }
コード例 #5
0
        public ActionResult CreateHashtag(Hashtag newHashtag)
        {
            var ops = OperationsFactory.CreateHashtagOps();

            ops.CreateHashtag(newHashtag);

            return(RedirectToAction("Index", "DraftPost"));
        }
コード例 #6
0
 public void Create(Hashtag hashtag)
 {
     using (var context = new TwitterEntities())
     {
         context.Hashtags.Add(hashtag);
         context.SaveChanges();
     }
 }
コード例 #7
0
        public HashtagDTO ConvertModelToDTO(Hashtag tag)
        {
            var dto = new HashtagDTO();

            dto.HashtagID = tag.HashtagID;
            dto.Text      = tag.Text;
            return(dto);
        }
コード例 #8
0
 public void AddHashTag(Hashtag newHash)
 {
     using (var ctx = new TechTruffleShuffleEntities())
     {
         ctx.Hashtag.Add(newHash);
         ctx.SaveChanges();
     }
 }
コード例 #9
0
        public Hashtag CreateBerichtHashtag(string berichtID, Hashtag hashtag)
        {
            Bericht bericht = ctx.Berichten.Find(berichtID);

            bericht.Hashtags.Add(hashtag);

            UpdateBericht(bericht);
            return(hashtag);
        }
コード例 #10
0
        private Hashtag PopulateHashtagsFromReader(SqlDataReader dr)
        {
            Hashtag hashtag = new Hashtag();

            hashtag.HashtagId    = (int)dr["HashtagID"];
            hashtag.HashtagTitle = dr["HashtagTitle"].ToString();
            hashtag.HashtagCount = int.Parse(dr["NumHts"].ToString());

            return(hashtag);
        }
コード例 #11
0
 public ActionResult Edit([Bind(Include = "ID,texto,PostID")] Hashtag hashtag)
 {
     if (ModelState.IsValid)
     {
         db.Entry(hashtag).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(hashtag));
 }
コード例 #12
0
        private static string GetFullDate(Hashtag hashtag)
        {
            string time = TimeRegex.Match(hashtag.Url).Groups.FirstOrDefault()?.Value;

            string formattedTime = time?.Insert(2, ":"); // Add hour:second seperator

            return(formattedTime == null
                ? hashtag.Date
                : $"{hashtag.Date} {formattedTime}");
        }
コード例 #13
0
        public ActionResult Submit()
        {
            ApplicationDbContext context = new ApplicationDbContext();
            var url    = Request["imgurl"];
            var gettag = Request["tags"];
            var userId = User.Identity.GetUserId();
            var tag    = context.Hashtags.FirstOrDefault(x => x.Name == gettag);

            if (url == null && gettag == null)
            {
            }
            else
            {
                //Hashtag hastags = new Hashtag() { Name = gettag };
                //Picture newImage = new Picture()
                //{
                //    PicUrl = url,
                //    TimeStamp = DateTime.Now,
                //    UserId = userId,
                //    Hashtag = hastags
                //};
                //context.Pictures.Add(newImage);
                //context.SaveChanges();
                if (tag == null)
                {
                    Hashtag hastags = new Hashtag()
                    {
                        Name = gettag
                    };
                    Picture newImage = new Picture()
                    {
                        PicUrl    = url,
                        TimeStamp = DateTime.Now,
                        UserId    = userId,
                        Hashtag   = hastags
                    };
                    context.Pictures.Add(newImage);
                    context.SaveChanges();
                }
                else
                {
                    Picture newImage = new Picture()
                    {
                        PicUrl    = url,
                        TimeStamp = DateTime.Now,
                        UserId    = userId,
                        Hashtag   = tag
                    };
                    context.Pictures.Add(newImage);
                    context.SaveChanges();
                }
            }

            return(View());
        }
コード例 #14
0
        public ActionResult Create([Bind(Include = "ID,texto,PostID")] Hashtag hashtag)
        {
            if (ModelState.IsValid)
            {
                db.Hashtag.Add(hashtag);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(hashtag));
        }
コード例 #15
0
ファイル: Tracker.cs プロジェクト: Honkmueller/D2DAS
        public Buff GetBuffFromMessage(string content, int amount)
        {
            Buff buff = null;

            foreach (KeyValuePair <string, Hashtag> kvp in App.Settings.Hashtags)
            {
                if (content.ToLower().Contains(kvp.Key.ToLower()))
                {
                    Hashtag hashtag = kvp.Value;

                    int duration = 0;
                    // Allow the [t]/$[d] syntax
                    string[] durationComponents = hashtag.Duration.Split(new string[] { "/$" }, StringSplitOptions.None);
                    // from now on, duration is kept in ms
                    duration = int.Parse(durationComponents[0]) * 1000;
                    if (durationComponents.Length > 1)
                    {
                        int multiplier = amount / int.Parse(durationComponents[1]);
                        duration *= multiplier;
                    }

                    int value = 0;

                    // Allow to use the current max value
                    if (hashtag.Value == "max")
                    {
                        if (hashtag.ValueType == BuffValueType.Total)
                        {
                            value = _hacker.GetMaxValue(hashtag.Type);
                        }
                        else
                        {
                            value = 100;
                        }
                    }
                    else
                    {
                        // Allow the [v]/$[d] syntax
                        string[] valueComponents = hashtag.Value.Split(new string[] { "/$" }, StringSplitOptions.None);
                        value = int.Parse(valueComponents[0]);
                        if (valueComponents.Length > 1)
                        {
                            int multiplier = amount / int.Parse(valueComponents[1]);
                            value *= multiplier;
                        }
                    }

                    buff = new Buff(hashtag.Type, hashtag.Effect, hashtag.ValueType, value, duration);
                    break;
                }
            }

            return(buff);
        }
コード例 #16
0
        public void Add(HashtagCreateDTO hashtagCreateDTO)
        {
            Hashtag hashtag = new Hashtag
            {
                Name        = hashtagCreateDTO.Name,
                CreatedDate = DateTime.Now,
            };

            _context.Hashtags.Add(hashtag);
            _context.SaveChanges();
        }
コード例 #17
0
        public bool DeleteHashtagById(int hashtagId)
        {
            Hashtag hashtag = GetHashtagById(hashtagId);

            if (hashtag != null)
            {
                _ctx.Entry(hashtag).State = System.Data.Entity.EntityState.Deleted;
                _ctx.SaveChanges();
            }
            return(true);
        }
コード例 #18
0
ファイル: AuthorFactory.cs プロジェクト: TheMulti0/Content
        public static Author Create(Hashtag hashtag, Seo seo)
        {
            Talent firstTalent = hashtag.Talents.FirstOrDefault();

            string name     = firstTalent?.Name ?? "גל\"צ";
            string imageUrl = firstTalent?.Img ?? seo.Image;

            return(new Author(
                       name,
                       GalatzConstants.ToAbsoluteUrl(imageUrl)));
        }
コード例 #19
0
        public ActionResult SubmitImgURL(FormCollection collection)
        {
            try
            {
                string imageURL = collection["SubmitImgURL"];
                string gettag   = collection["tags"];


                var userId = User.Identity.GetUserId();
                var tag    = context.Hashtags.FirstOrDefault(x => x.Name == gettag);
                if (imageURL == string.Empty)
                {
                    ModelState.AddModelError(string.Empty, "Sorry, something went wrong, please try again.");
                }
                else
                {
                    if (tag == null)
                    {
                        Hashtag hastags = new Hashtag()
                        {
                            Name = gettag
                        };
                        Picture newImage = new Picture()
                        {
                            PicUrl    = imageURL,
                            TimeStamp = DateTime.Now,
                            UserId    = userId,
                            Hashtag   = hastags
                        };
                        context.Pictures.Add(newImage);
                        context.SaveChanges();
                        return(Redirect("/Image/FullImage?fileName=" + newImage.Id));
                    }
                    else
                    {
                        Picture newImage = new Picture()
                        {
                            PicUrl    = imageURL,
                            TimeStamp = DateTime.Now,
                            UserId    = userId,
                            Hashtag   = tag
                        };
                        context.Pictures.Add(newImage);
                        context.SaveChanges();
                        return(Redirect("/Image/FullImage?fileName=" + newImage.Id));
                    }
                }
            }
            catch (Exception)
            {
                ModelState.AddModelError("Submit", "Sorry, something went wrong, please try again");
            }
            return(Redirect("/Image/Submit"));
        }
コード例 #20
0
        public async Task <IHttpActionResult> GetHashtag(int id)
        {
            Hashtag hashtag = await db.Hashtags.FindAsync(id);

            if (hashtag == null)
            {
                return(NotFound());
            }

            return(Ok(hashtag));
        }
コード例 #21
0
 public IEnumerable <Tweet> GetTaggedTweets(Hashtag hashtag)
 {
     return(_context.Hashtags
            .Include(h => h.TweetHashtags)
            .ThenInclude(th => th.Tweet)
            .ThenInclude(t => t.Author)
            .First(h => h.Label == hashtag.Label)
            .TweetHashtags
            .Where(th => !th.Tweet.Deleted)
            .Select(th => th.Tweet)
            .ToList());
 }
コード例 #22
0
        public async Task <bool> DeleteHashtag(int hashtagID)
        {
            Hashtag tag = await this.FindHashtagByIDAsync(hashtagID);

            if (tag != null)
            {
                context.Hashtags.Remove(tag);
                return(true);
            }

            return(false);
        }
コード例 #23
0
        public Hashtag Insert(Hashtag entity)
        {
            var data = this.hashtags.ToList();

            entity.Id = data.Count + 1;

            data.Add(entity);

            this.hashtags = data.AsQueryable();

            return(entity);
        }
コード例 #24
0
        // Toevoegen van een SubjectMessage adhv een 'Message' en een 'Hashtag'
        public void AddSubjectMessage(Message msg, Hashtag hashtag)
        {
            initNonExistingRepo();

            SubjectMessage subjMess = new SubjectMessage()
            {
                Msg     = msg,
                Hashtag = hashtag
            };

            repo.AddSubjectMsg(subjMess);
        }
コード例 #25
0
ファイル: HashtagOpsTest.cs プロジェクト: JakeSaliga/TechBlog
        public void CreateNewCategoryEmptyTypeDbTest()
        {
            var ops     = OperationsFactory.CreateHashtagOps();
            var hashtag = new Hashtag()
            {
            };

            ops.CreateHashtag(hashtag);
            var list = ops.ListAllHashtags();

            Assert.AreEqual(1, list.Count);
        }
コード例 #26
0
        public IHttpActionResult GetHashtag(int id)
        {
            Hashtag hashtag = db.Hashtags.Include(l => l.POIs).Where(l => l.ID == id).SingleOrDefault();

            if (hashtag == null)
            {
                return(NotFound());
            }
            HashTagModel newMdlHash = new HashTagModel(hashtag);

            return(Ok(newMdlHash));
        }
コード例 #27
0
        public async Task <IHttpActionResult> PostHashtag(Hashtag hashtag)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Hashtags.Add(hashtag);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = hashtag.HashtagID }, hashtag));
        }
コード例 #28
0
        public void Update(Hashtag entity)
        {
            var oldPoi = this.Get(entity.Id);

            var data = this.hashtags.ToList();

            data.Remove(oldPoi);

            data.Add(entity);

            this.hashtags = data.AsQueryable();
        }
コード例 #29
0
        public static POI ConvertDTOToModel(POIDTO dto)
        {
            POI poi = new POI();

            poi.POIID         = dto.ID;
            poi.Name          = dto.Name;
            poi.Description   = dto.Description;
            poi.OpenHour      = dto.OpenHour;
            poi.CloseHour     = dto.CloseHour;
            poi.VisitDuration = dto.VisitDuration;
            poi.GPS_Lat       = dto.GPS_Lat;
            poi.GPS_Long      = dto.GPS_Long;
            poi.Altitude      = dto.Altitude;
            poi.ConnectedPOIs = new List <POI>();
            poi.Hashtags      = new List <Hashtag>();

            if (dto.ConnectedPOI != null)
            {
                foreach (POIConnectedDTO poiDTO in dto.ConnectedPOI)
                {
                    POI poiCon = new POI();

                    poiCon.POIID = poiDTO.ID;
                    poiCon.Name  = poiDTO.Name;

                    poi.ConnectedPOIs.Add(poiCon);
                }
            }

            if (dto.Creator != null)
            {
                poi.Creator = dto.Creator;
            }

            if (dto.Approved != null)
            {
                poi.Approved = dto.Approved;
            }

            if (dto.Hashtags != null)
            {
                foreach (HashtagDTO tagDTO in dto.Hashtags)
                {
                    Hashtag tag = new Hashtag();
                    tag.HashtagID      = tagDTO.HashtagID;
                    tag.Text           = tagDTO.Text;
                    tag.ReferencedPOIs = new List <POI>();
                    poi.Hashtags.Add(tag);
                }
            }

            return(poi);
        }
コード例 #30
0
        private EdgeHashtagToMedia GetEdgeHashtagToMedia(Hashtag Hashtag)
        {
            EdgeHashtagToMedia EdgeHashtagToMedia = new EdgeHashtagToMedia();

            EdgeHashtagToMedia.PageInfo = Hashtag.EdgeHashtagToMedia.PageInfo;
            EdgeHashtagToMedia.Edges    = new List <EdgeHashtagToMediaEdges>();

            if (Hashtag.EdgeHashtagToMedia == null)
            {
                return(null);
            }

            var medias = Hashtag.EdgeHashtagToMedia;

            var ImageMedias   = medias.Edges.Where(c => c.Node.Typename == MediaType.Image).ToList();
            var SidecarMedias = medias.Edges.Where(c => c.Node.Typename == MediaType.Sidecar).ToList();
            var VideosMedias  = medias.Edges.Where(c => c.Node.Typename == MediaType.Video).ToList();

            foreach (var image in ImageMedias)
            {
                EdgeHashtagToMedia.Edges.Add(new EdgeHashtagToMediaEdges()
                {
                    Node = image.Node
                });
            }

            foreach (var sidecar in SidecarMedias)
            {
                var shortcode = sidecar.Node.Shortcode;

                var sidecarShortcodeData = GetShortcodeHashtagMedia(shortcode);

                EdgeHashtagToMedia.Edges.Add(new EdgeHashtagToMediaEdges()
                {
                    ShortcodeNode = sidecarShortcodeData.Data.ShortcodeMediaHashtag
                });
            }

            foreach (var video in VideosMedias)
            {
                var shortcode = video.Node.Shortcode;

                var videoShortcodeData = GetShortcodeHashtagMedia(shortcode);

                EdgeHashtagToMedia.Edges.Add(new EdgeHashtagToMediaEdges()
                {
                    ShortcodeNode = videoShortcodeData.Data.ShortcodeMediaHashtag
                });
            }

            return(EdgeHashtagToMedia);
        }
コード例 #31
0
        public void CreateNewHashtagDbTest()
        {
            var repo    = OperationsFactory.CreateHashtagOps();
            var hashtag = new Hashtag()
            {
                HashtagType = "Trends",
            };

            repo.CreateHashtag(hashtag);
            var list = repo.ListAllHashtags();

            Assert.AreEqual(1, list.Count);
        }
コード例 #32
0
        public IHttpActionResult SearchPostTag([FromBody] Hashtag hastagObj)
        {
            IList <User> UserList = userBusinessLogic.GetAllTweetBasedOnHashTags(hastagObj);

            if (UserList != null)
            {
                return(Ok(UserList));
            }
            else
            {
                return(NotFound());
            }
        }