public void DeleteBlurb(int id) { foreach (Canvas canvas in CanvasCollection) { canvas.CanvasObjects.RemoveAll(co => co.BlurbId == id); } Blurb blurbToRemove = BlurbCollection.SingleOrDefault(b => b.Id == id); BlurbCollection.Remove(blurbToRemove); IsDirty = true; }
public void CreateNewBlurb(Blurb newBlurb) { int id = 1; Blurb lastBlurb = BlurbCollection.FirstOrDefault(); if (lastBlurb != null) { id = lastBlurb.Id++; } newBlurb.Id = id; BlurbCollection.Add(newBlurb); IsDirty = true; }
private bool BlurbMatchesTag(Blurb blurb) { bool result = false; if (SelectedTag == null) { result = true; } else if (blurb.Tags.Contains(SelectedTag))//this might not work, might need to write custom comparer { result = true; } return(result); }
/// <summary> /// Updates properties blurb object /// </summary> /// <param name="blurb"></param> /// <returns></returns> public async Task <Blurb> UpdateBlurb(Blurb blurb) { Blurb blurbInDb = await _context.Blurbs.Include(b => b.Notes).FirstOrDefaultAsync(b => b.BlurbId == blurb.BlurbId); //Deletes all the notes in the db blurb entry that have been excluded in the blurb param var blurbDbNotesExcluded = blurbInDb.Notes.Except(blurb.Notes); _context.Notes.RemoveRange(blurbDbNotesExcluded); _context.Entry(blurbInDb).State = EntityState.Detached; _context.SaveChanges(); _context.Update(blurb); _context.Entry(blurb).State = EntityState.Modified; _context.SaveChanges(); return(await _context.Blurbs.Include(b => b.Media).Include(b => b.User).Include(b => b.Notes).FirstOrDefaultAsync(b => b.BlurbId == blurb.BlurbId)); }
private bool BlurbMatchesSearch(Blurb blurb) { bool result = false; if (blurb.Name.Contains(SearchText)) { result = true; } else if (blurb.Description.Contains(SearchText)) { result = true; } else if (blurb.Body.Contains(SearchText))//make this a preference to reduce search times { result = true; } return(result); }
/// <summary> /// Returns true if the user has permission to see the blurb, false if they do not /// </summary> /// <param name="user"></param> /// <param name="blurb"></param> /// <returns></returns> public bool CanSeeBlurb(User user, Blurb blurb) { if (blurb.Privacy == Privacy.Public) { return(true); } else //If the list of IDs in the following list contains this id, return true { var followingListIds = user.GetFollowingList().Select(x => x.UserId); if (followingListIds.Contains(blurb.UserId) && blurb.Privacy == Privacy.FollowersOnly) { return(true); } else { return(false); } } }
//take text file text and interpret into blurb Blurb ParseBlurbFromText(List <string> text) { Blurb myBlurb = new Blurb(); myBlurb.dialogue = new List <string>(); myBlurb.sprites = new List <TedMoods>(); foreach (string line in text) { //for each line, '/' is the character separating the tedmood enum value from the dialogue string string[] components = line.Split('/'); //each line should have two components: a sprite and a line of dialogue if (components.Length >= 2) { myBlurb.dialogue.Add(components[1]); int sprite = 0; int.TryParse(components[0], out sprite); myBlurb.sprites.Add((TedMoods)sprite); } } return(myBlurb); }
public async Task <ActionResult <Blurb> > EditMessage(Blurb blurb) { return(await _repository.EditBlurbMessageAsync(blurb.BlurbId, blurb.Message)); }
public TagSelectionWindowViewModel(DataRepository dataRepository, Blurb blurb) { this.dataRepository = dataRepository; currentBlurb = blurb; TagsList = new ObservableCollection <Tag>(currentBlurb.Tags); }
public VolatileMethodBlurb(string img, string msg, string name, bool top, bool showall, Blurb next, ConvoMethod method) : base(img, msg, name, top, showall, next) { this.method = method; }
public VolatileBlurb(string img, string msg, string name, bool top, bool showall, Blurb next) : base(img, msg, name, top, showall) { this.next = next; }
public static uint RegisterBlurb(Blurb alpha) { blurbs[nextId] = alpha; nextId++; return(nextId - 1); }
public async Task <ActionResult <Blurb> > EditScore(Blurb blurb, double newScore) { return(await _repository.EditBlurbScoreAsync(blurb.BlurbId, newScore)); }
public BlurbEditWindowViewModel(DataRepository dataRepository) { this.dataRepository = dataRepository; currentBlurb = new Blurb(); Name = "New Blurb"; }
public async Task <ActionResult <Blurb> > Edit(Blurb blurb) { return(await _repository.UpdateBlurb(blurb)); }
public async Task <ActionResult <Blurb> > Add(Blurb blurb) { return(await _repository.AddBlurbToDbAsync(blurb)); }
public static uint RegisterBlurb(Blurb alpha) { blurbs[nextId] = alpha; nextId++; return nextId - 1; }
public BlurbEditWindowViewModel(DataRepository dataRepository, Blurb blurb) { this.dataRepository = dataRepository; currentBlurb = blurb; UpdateTagList(); }
/// <summary> /// Adds the blurb to the db and saves changes /// </summary> /// <param name="context"></param> /// <param name="blurb"></param> public async Task <Blurb> AddBlurbToDbAsync(Blurb blurb) { _context.Add(blurb); _context.SaveChanges(); return(await _context.Blurbs.Include(x => x.Media).Include(x => x.User).FirstOrDefaultAsync(b => b == blurb)); }