Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        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;
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        /// <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));
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        /// <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);
                }
            }
        }
Esempio n. 7
0
    //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);
    }
Esempio n. 8
0
 public async Task <ActionResult <Blurb> > EditMessage(Blurb blurb)
 {
     return(await _repository.EditBlurbMessageAsync(blurb.BlurbId, blurb.Message));
 }
Esempio n. 9
0
 public TagSelectionWindowViewModel(DataRepository dataRepository, Blurb blurb)
 {
     this.dataRepository = dataRepository;
     currentBlurb        = blurb;
     TagsList            = new ObservableCollection <Tag>(currentBlurb.Tags);
 }
Esempio n. 10
0
 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;
 }
Esempio n. 11
0
 public VolatileBlurb(string img, string msg, string name, bool top, bool showall, Blurb next)
     : base(img, msg, name, top, showall)
 {
     this.next = next;
 }
Esempio n. 12
0
 public static uint RegisterBlurb(Blurb alpha)
 {
     blurbs[nextId] = alpha;
     nextId++;
     return(nextId - 1);
 }
Esempio n. 13
0
 public async Task <ActionResult <Blurb> > EditScore(Blurb blurb, double newScore)
 {
     return(await _repository.EditBlurbScoreAsync(blurb.BlurbId, newScore));
 }
Esempio n. 14
0
 public BlurbEditWindowViewModel(DataRepository dataRepository)
 {
     this.dataRepository = dataRepository;
     currentBlurb        = new Blurb();
     Name = "New Blurb";
 }
Esempio n. 15
0
 public async Task <ActionResult <Blurb> > Edit(Blurb blurb)
 {
     return(await _repository.UpdateBlurb(blurb));
 }
Esempio n. 16
0
 public async Task <ActionResult <Blurb> > Add(Blurb blurb)
 {
     return(await _repository.AddBlurbToDbAsync(blurb));
 }
Esempio n. 17
0
 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;
 }
Esempio n. 18
0
 public VolatileBlurb(string img, string msg, string name, bool top, bool showall, Blurb next)
     : base(img, msg, name, top, showall)
 {
     this.next = next;
 }
Esempio n. 19
0
 public static uint RegisterBlurb(Blurb alpha)
 {
     blurbs[nextId] = alpha;
     nextId++;
     return nextId - 1;
 }
Esempio n. 20
0
 public BlurbEditWindowViewModel(DataRepository dataRepository, Blurb blurb)
 {
     this.dataRepository = dataRepository;
     currentBlurb        = blurb;
     UpdateTagList();
 }
Esempio n. 21
0
 /// <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));
 }