Esempio n. 1
0
        public async Task <ActionResult <Catogory> > PostCatogory(Catogory catogory)
        {
            _context.Catogory.Add(catogory);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCatogory", new { id = catogory.CatogoryId }, catogory));
        }
Esempio n. 2
0
        public async Task <IActionResult> PutCatogory(int id, Catogory catogory)
        {
            if (id != catogory.CatogoryId)
            {
                return(BadRequest());
            }

            _context.Entry(catogory).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CatogoryExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
 public RedditImageDownloader(string localPath, string fileName, string subreddit, Catogory catogory, int numberOfImages)
 {
     this._localPath = localPath;
     _fileNamePrefix = fileName;
     _subreddit      = subreddit;
     _catogory       = catogory;
     _numberOfImages = numberOfImages;
 }
        private IEnumerable <Post> _getSelectedPosts(Subreddit subreddit, Catogory selectedCategory)
        {
            switch (selectedCategory)
            {
            case Catogory.Hot:
                return(subreddit.Hot);

            case Catogory.New:
                return(subreddit.New);

            case Catogory.Posts:
                return(subreddit.Posts);

            case Catogory.UnmoderatedLinks:
                return(subreddit.UnmoderatedLinks);

            default:
                throw new Exception("Please select a category for the search.");
            }
        }