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; } }
public ActionResult DeleteConfirmed(int id) { Hashtag hashtag = db.Hashtag.Find(id); db.Hashtag.Remove(hashtag); db.SaveChanges(); return(RedirectToAction("Index")); }
public void Delete(Hashtag entity) { var data = this.hashtags.ToList(); data.Remove(entity); this.hashtags = data.AsQueryable(); }
public void Test_Hashtag_Insert() { var newTag = new Hashtag("Mock Tag", poi, user); this.repository.Insert(newTag); Assert.AreEqual(5, repository.Count()); }
public ActionResult CreateHashtag(Hashtag newHashtag) { var ops = OperationsFactory.CreateHashtagOps(); ops.CreateHashtag(newHashtag); return(RedirectToAction("Index", "DraftPost")); }
public void Create(Hashtag hashtag) { using (var context = new TwitterEntities()) { context.Hashtags.Add(hashtag); context.SaveChanges(); } }
public HashtagDTO ConvertModelToDTO(Hashtag tag) { var dto = new HashtagDTO(); dto.HashtagID = tag.HashtagID; dto.Text = tag.Text; return(dto); }
public void AddHashTag(Hashtag newHash) { using (var ctx = new TechTruffleShuffleEntities()) { ctx.Hashtag.Add(newHash); ctx.SaveChanges(); } }
public Hashtag CreateBerichtHashtag(string berichtID, Hashtag hashtag) { Bericht bericht = ctx.Berichten.Find(berichtID); bericht.Hashtags.Add(hashtag); UpdateBericht(bericht); return(hashtag); }
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); }
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)); }
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}"); }
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()); }
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)); }
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); }
public void Add(HashtagCreateDTO hashtagCreateDTO) { Hashtag hashtag = new Hashtag { Name = hashtagCreateDTO.Name, CreatedDate = DateTime.Now, }; _context.Hashtags.Add(hashtag); _context.SaveChanges(); }
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); }
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))); }
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")); }
public async Task <IHttpActionResult> GetHashtag(int id) { Hashtag hashtag = await db.Hashtags.FindAsync(id); if (hashtag == null) { return(NotFound()); } return(Ok(hashtag)); }
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()); }
public async Task <bool> DeleteHashtag(int hashtagID) { Hashtag tag = await this.FindHashtagByIDAsync(hashtagID); if (tag != null) { context.Hashtags.Remove(tag); return(true); } return(false); }
public Hashtag Insert(Hashtag entity) { var data = this.hashtags.ToList(); entity.Id = data.Count + 1; data.Add(entity); this.hashtags = data.AsQueryable(); return(entity); }
// 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); }
public void CreateNewCategoryEmptyTypeDbTest() { var ops = OperationsFactory.CreateHashtagOps(); var hashtag = new Hashtag() { }; ops.CreateHashtag(hashtag); var list = ops.ListAllHashtags(); Assert.AreEqual(1, list.Count); }
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)); }
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)); }
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(); }
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); }
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); }
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); }
public IHttpActionResult SearchPostTag([FromBody] Hashtag hastagObj) { IList <User> UserList = userBusinessLogic.GetAllTweetBasedOnHashTags(hastagObj); if (UserList != null) { return(Ok(UserList)); } else { return(NotFound()); } }