//Update
        public bool  UpdateExistingContent(string orginialTitle, StreamingContent newContent)
        {
            StreamingContent oldContent = GetContentByTitle(orginialTitle);

            if (oldContent != null)
            {
                oldContent.Title            = newContent.Title;
                oldContent.Description      = newContent.Description;
                oldContent.MaturityRating   = newContent.MaturityRating;
                oldContent.IsFamilyFriendly = newContent.IsFamilyFriendly;
                oldContent.StarRating       = newContent.StarRating;
                oldContent.TypeOfGenre      = newContent.TypeOfGenre;
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        //Delete
        public bool RemoveContentFromList(string title)
        {
            StreamingContent content = GetContentByTitle(title);

            if (content == null)
            {
                return(false);
            }
            int initialCount = _listOfContent.Count;

            _listOfContent.Remove(content);
            if (initialCount > _listOfContent.Count)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#3
0
        //Delete
        public bool RemoveContentFromList(string title)
        {     //                            //call Method
            StreamingContent Content = GetContentByTitle(title);

            if (Content == null)
            {
                return(false);
            }                                   //Count is a property of a list
            int initialCount = listofContent.Count;

            _listOfContent.Remove(content);

            if (initialCount > _listOfContent.Count)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        // UPDATE
        public bool UpdateExistingContent(StreamingContent updatedContent, string originalTitle)
        {
            StreamingContent content = GetContentByTitle(originalTitle);

            if (content != null)
            {
                int itemIndex = _contentDirectory.IndexOf(content);
                _contentDirectory[itemIndex] = updatedContent;
                return(true);
            }

            return(false);


            // Find the target content by originalTitle
            foreach (StreamingContent item in _contentDirectory)
            {
                if (item.Title.ToLower() == originalTitle.ToLower())
                {
                    // Update the target content with updatedContent properties/values

                    //item.Title = updatedContent.Title;
                    //item.Description = updatedContent.Description;
                    //item.Genre = updatedContent.Genre;
                    //item.MaturityRating = updatedContent.MaturityRating;
                    //item.ReleaseYear = updatedContent.ReleaseYear;
                    //item.StarRating = updatedContent.StarRating;

                    // Find the index that item is at
                    int itemIndex = _contentDirectory.IndexOf(item);
                    // Slot in updatedContent into that index on the List
                    _contentDirectory[itemIndex] = updatedContent;

                    return(true);
                }
            }

            return(false);
        }
        // Delete
        public bool RemoveContentFromList(string title)
        {
            StreamingContent content = GetContentByTitle(title); //new StreamingContent object called content; going to call method GetContentByTitle

            if (content == null)                                 // usese object content that is either True or False
            {
                return(false);
            }

            int initialCount = _listOfContent.Count; // counts the number of items on the list

            _listOfContent.Remove(content);          // actually removes the content from list

            if (initialCount > _listOfContent.Count) // verifies that the item has been removed
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#6
0
        //update
        public bool UpdateExistingContent(string originalTitle, StreamingContent newContent)
        {
            //find the content
            StreamingContent OldContent = GetContentByTitle(originalTitle);

            //update the content
            if (OldContent != null)
            {
                OldContent.Title            = newContent.Title;
                OldContent.Description      = newContent.Description;
                OldContent.MaturityRating   = newContent.MaturityRating;
                OldContent.IsFamilyFriendly = newContent.IsFamilyFriendly;
                OldContent.StarRating       = newContent.StarRating;
                OldContent.TypeOfGenre      = newContent.TypeOfGenre;

                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#7
0
        //Delete (CRUD)
        public bool RemoveContentFromList(string title)
        {
            StreamingContent content = GetContentByTitle(title);

            if (content == null) //is content null? program stops
            {
                return(false);
            }

            int initialCount = _listOfContent.Count; //use count method to determine list

            _listOfContent.Remove(content);          //use Remove method to remove content

            if (initialCount > _listOfContent.Count) //use count and expression to determine if we now have less titles
            {
                return(true);                        //if we do, true
            }
            else
            {
                return(false); //if not, false
            }
        }
示例#8
0
        //Update
        public bool UpdateExistingContent(string originalTitle, StreamingContent newContent)
        {
            //Find the content
            StreamingContent oldContent = GetContentByTitle(originalTitle); //Object newVar = Method(parameter)

            if (oldContent != null)
            {
                oldContent.Title            = newContent.Title;
                oldContent.Description      = newContent.Description;
                oldContent.MaturityRating   = newContent.MaturityRating;
                oldContent.IsFamilyFriendly = newContent.IsFamilyFriendly;
                oldContent.StarRating       = newContent.StarRating;
                oldContent.TypeOfGenre      = newContent.TypeOfGenre;

                return(true);
            }
            else
            {
                return(false);
            }

            //Update the content
        }
        // Update

        public bool UpdateExistingContent(string originalTitle, StreamingContent newContent)
        {
            //Find content
            StreamingContent oldContent = GetContentByTitle(originalTitle);



            // Update content

            if (oldContent != null)
            {
                oldContent.Title            = newContent.Title;
                oldContent.Description      = newContent.Description;
                oldContent.MaturityRating   = newContent.MaturityRating;
                oldContent.IsFamilyFriendly = newContent.IsFamilyFriendly;
                oldContent.StarRating       = newContent.StarRating;
                oldContent.TypeOfGenre      = newContent.TypeOfGenre;
                return(true);  //this gives us feedback that something has been done.
            }
            else
            {
                return(false);
            }
        }
示例#10
0
 //Create
 //This method adds a SC to our List<StreamingContent>. It takes in an SC as a parameter. We build out all the properties of that object in the UI, then call this method to add it to a list
 public void AddContentToList(StreamingContent content)
 {
     _listOfContent.Add(content);
 }
 // DELETE
 public bool DeleteExistingContent(StreamingContent content)
 {
     return(_contentDirectory.Remove(content));
 }
        // Delete Content By Title
        // Give a title (take in) parameter
        // Find the content by its title
        // If I find that content, delete the content
        // return a true/false whether it worked or not
        public bool DeleteContentByTitle(string title)
        {
            StreamingContent targetContent = GetContentByTitle(title);

            return(DeleteExistingContent(targetContent));
        }
示例#13
0
        /* Methods should have a single responsibility principle (only do one thing). For example,
         * our Create and Read methods should not be combined.*/

        //Create
        // Method signature // parameter type of Streaming Content object then name (content)
        public void AddContentToList(StreamingContent content)
        {
            // Calling list object that holds StreamingContent using the dot operator and Add method
            // We gave our field an underscore and camel case to denote it as a field
            _listOfContent.Add(content);
        }
 // CRUD
 // CREATE
 public void AddContentToDirectory(StreamingContent content)
 {
     _contentDirectory.Add(content);
 }
        private List <StreamingContent> _listOfContent = new List <StreamingContent>(); //<--- _listOfContent is a field

        //CRUD: Create, Read, Update, Delete
        //Create
        public void AddContentToList(StreamingContent content)
        {
            _listOfContent.Add(content);   // <-- field is _ camel case  ; properties is pascal case (example: ListOfContent)
        }
示例#16
0
        private List <StreamingContent> _listOfContent = new List <StreamingContent>(); //variable field

        //Create
        public void AddContentToList(StreamingContent content) //access - void(no return type) - Name of Object(object type)
        {
            _listOfContent.Add(content);                       // _field.Add(parameter)
        }
        private List <StreamingContent> _listOfContent = new List <StreamingContent>(); // of our CRUD methods can use the same Lists by way of a field


        // Create

        // use void to follow single purpose responsiblity; don't need to return anything bc we are just adding something to the list.
        // public so anybody can see it
        // what do we want to do with the content object witha  StreamingContent class
        // need to give it a StreamingContect

        public void AddContentToList(StreamingContent content)
        {
            _listOfContent.Add(content); //use underscore to show this is field and not a property; use camelCase
        }