Example #1
0
        public ActionResult DeleteGenre(int uid)
        {
            var temp = db.Genres.Where(x => x.Id == uid);

            if (temp.ToList().Count > 0)
            {
                var temp_elem = temp.First();

                var tempGS = db.Sound_gener.Where(x => x.Id_gener == uid);

                if (tempGS.ToList().Count > 0)
                {
                    var temp_elem2 = tempGS.First();

                    db.Sound_gener.Remove(temp_elem2);
                }
                db.Genres.Remove(temp_elem);

                db.SaveChanges();
            }


            var temp_genres = new GenresModel()
            {
                genre = db.Genres.ToList()
            };

            return(RedirectToAction("EditGenre"));
        }
        public async Task <IActionResult> Edit(int id, [Bind("GenreID,GenreName")] GenresModel genresModel)
        {
            if (id != genresModel.GenreID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(genresModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GenresModelExists(genresModel.GenreID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(genresModel));
        }
Example #3
0
        public ActionResult CreateGenre(GenresModel model)
        {
            if (Session["userID"] != null)
            {
                if (Session["Group_ID"].ToString() == "2")
                {
                    var  data   = Loadgenre();
                    bool Exists = false;

                    foreach (var genre in data)
                    {
                        if (genre.Genre == model.Genre)
                        {
                            Exists = true;
                        }
                    }

                    if (!Exists)
                    {
                        Creategenre(model.Genre);
                    }

                    return(RedirectToAction("Index", "Home"));
                }
            }
            return(RedirectToAction("Index", "Home"));
        }
Example #4
0
        private void FetchStaticData()
        {
            //Genres
            var genresApiResponse = GetTMDbAPIData("/genre/movie/list?language=en-US");
            var genresDto         = JsonConvert.DeserializeObject <GenresDto>(genresApiResponse);

            this._genresModel = _autoMapper.DefaultContext.Mapper.Map <GenresDto, GenresModel>(genresDto);
        }
        private dynamic Genres(dynamic parameters)
        {
            var allGenres   = _genreDataProvider.GetAll().OrderBy(g => g.Pkid).ToList();
            var genresModel = new GenresModel {
                GenresPresent = allGenres.Any(), Genres = allGenres
            };

            return(View["mp3player/genrelist", genresModel]);
        }
        public async Task <IActionResult> Create([Bind("GenreID,GenreName")] GenresModel genresModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(genresModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(genresModel));
        }
Example #7
0
        public IActionResult Genres(int?id)
        {
            GenresModel model = new GenresModel();

            model.Genres = genreManager.GetAllCategories();
            if (id.HasValue)
            {
                model.Films     = cinemaManager.GetByCategory(id.Value);
                model.ActiveCat = genreManager.GetCategory(id.Value);
            }

            return(View(model));
        }
        public void Post(GenresModel model)
        {
            var mongoDbClient = new MongoClient("mongodb://127.0.0.1:27017");
            var mongoDbServer = mongoDbClient.GetDatabase("SocialNetworks");

            var document = new BsonDocument
            {
                { "genre_ID", model.genre_id },
                { "genre_type", model.genre_type },
            };

            var collection = mongoDbServer.GetCollection <BsonDocument>("Genres");

            collection.InsertOneAsync(document);
        }
Example #9
0
        public ActionResult EditGenre()
        {
            if (Session["Status"] != null && Session["Status"].ToString() == "0")
            {
                var temp_genres = new GenresModel()
                {
                    genre = db.Genres.ToList()
                };

                return(View(temp_genres));
            }

            else
            {
                return(RedirectToAction("Index"));
            }
        }
Example #10
0
        public ActionResult Edit(int uid, string uname)
        {
            var temp = db.Genres.Where(x => x.Id == uid);

            if (temp.ToList().Count > 0)
            {
                var temp_elem = temp.First();
                temp_elem.Name = uname;
                db.SaveChanges();
            }


            var temp_genres = new GenresModel()
            {
                genre = db.Genres.ToList()
            };

            return(RedirectToAction("EditGenre"));
        }
        public async Task <GenresModel> Get(string genre_ID)
        {
            var    mongoDbClient = new MongoClient("mongodb://127.0.0.1:27017");
            var    mongoDbServer = mongoDbClient.GetDatabase("SocialNetworks");
            string genre_id      = genre_ID;

            GenresModel genre      = new GenresModel();
            var         collection = mongoDbServer.GetCollection <BsonDocument>("Genres");
            var         filter     = Builders <BsonDocument> .Filter.Eq("genre_id", genre_id);

            var result = await collection.Find(filter).ToListAsync();

            foreach (BsonDocument item in result)
            {
                genre.genre_id   = item.GetElement("genre_id").Value.ToString();
                genre.genre_type = item.GetElement("genre_type").Value.ToString();
            }
            var json = new JavaScriptSerializer().Serialize(genre);

            return(genre);
        }
        public async Task <List <GenresModel> > Get()
        {
            var mongoDbClient = new MongoClient("mongodb://127.0.0.1:27017");
            var mongoDbServer = mongoDbClient.GetDatabase("SocialNetworks");


            var collection = mongoDbServer.GetCollection <BsonDocument>("Genres");
            var filter     = new BsonDocument();
            var result     = await collection.Find(filter).ToListAsync();

            List <GenresModel> listOfGenres = new List <GenresModel>();

            foreach (BsonDocument item in result)
            {
                GenresModel genre = new GenresModel();
                genre.genre_id   = item.GetElement("genre_ID").Value.ToString();
                genre.genre_type = item.GetElement("genre_type").Value.ToString();
                listOfGenres.Add(genre);
            }
            var json = new JavaScriptSerializer().Serialize(listOfGenres);

            return(listOfGenres);
        }