Beispiel #1
0
        public IHttpActionResult Put(Genre genre)
        {
            var dbGenre = Mapper.Map <DbGenre>(genre);

            _genreService.CreateGenre(dbGenre);
            return(Json(Mapper.Map <Genre>(dbGenre), new JsonSerializerSettings {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            }));
        }
Beispiel #2
0
        public ActionResult Create(GenreSinglePageViewModel model)
        {
            if (ModelState.IsValid)
            {
                _genreService.CreateGenre(model.GenreViewModel.ConvertToModel());
                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
Beispiel #3
0
        public ActionResult Create(CreateGenreBindingModel model)
        {
            if (ModelState.IsValid)
            {
                service.CreateGenre(model);

                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
        public ActionResult Create(CreateGenreViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Create());
            }
            var genre = mapper.Map <CreateGenreViewModel, Genre>(model);

            genreService.CreateGenre(genre);

            return(RedirectToAction(nameof(Index)));
        }
        public async Task <IActionResult> PostGenre(GenreDto genre)
        {
            try
            {
                await _genreService.CreateGenre(genre);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(Problem(ex.Message));
            }
        }
Beispiel #6
0
        public async Task <IActionResult> Create(GenreCreateViewModel genreCreateViewModel)
        {
            if (ModelState.IsValid)
            {
                await _genreService.CreateGenre(genreCreateViewModel);

                _flashMessage.Confirmation("Genre has been created.");

                return(RedirectToAction(nameof(Index)));
            }

            return(View(genreCreateViewModel));
        }
Beispiel #7
0
        public IActionResult CreateGenre([FromBody] GenreDTO genreDTO)
        {
            try
            {
                GenreService.CreateGenre(genreDTO);
            }
            catch (ArgumentException e)
            {
                log.LogError("Something happened when creating a genre. " + e.Message);
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }

            return(Ok(StatusCodes.Status200OK));
        }
        public ActionResult Create(CreateGenreViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var request = new CreateGenreRequest {
                Name = model.Name, Description = model.Description
            };

            _genreService.CreateGenre(request);

            return(RedirectToAction("Index"));
        }
Beispiel #9
0
        public ActionResult Create(GenreSinglePageViewModel model)
        {
            CreateGenreRequest  request  = model.GenreViewModel.ConvertToCreateGenreRequest();
            CreateGenreResponse response = _genreService.CreateGenre(request);

            if (response.Success)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                model.Success = false;
                model.Message = response.Message;
                return(View(model));
            }
        }
Beispiel #10
0
        public async Task <IActionResult> Post([FromBody] GenreCreateOrUpdateDto genre)
        {
            var result = await _genreService.CreateGenre(genre);

            if (result.IsSuccessful)
            {
                return(Ok(result.Payload));
            }

            if (result.Payload != null)
            {
                return(Conflict("Object already exists!"));
            }

            return(StatusCode(500, result.Message));
        }
Beispiel #11
0
        public async Task <IActionResult> OnGetAsync(string id)
        {
            if (id != null)
            {
                Genre = await GenreService.GetAsync(id);
            }
            else
            {
                Genre = GenreService.CreateGenre();
            }

            if (Genre == null)
            {
                return(NotFound());
            }

            return(Page());
        }
Beispiel #12
0
        public IActionResult Create(GenreViewModel genre)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            var genreId  = Guid.NewGuid();
            var genreNew = new Genre {
                Name = genre.Name, Id = genreId
            };

            if (genre.ParentGenre != null)
            {
                var genreModel = _genreService.GetGenreByName(genre.ParentGenre);
                genreNew.ParentGenreId = genreModel.Id;
            }

            _genreService.CreateGenre(genreNew);
            _genreService.AddGenreTranslate(genre.NameRu, "ru", genreId);

            return(RedirectToAction(nameof(Index)));
        }
Beispiel #13
0
        public IActionResult Insert([FromForm] GenreViewModel genre)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var genreId  = Guid.NewGuid();
            var genreNew = new Genre()
            {
                Name = genre.Name, Id = genreId
            };

            if (genre.ParentGenre != null)
            {
                var genreModel = _genreService.GetGenreByName(genre.ParentGenre);
                genreNew.ParentGenreId = genreModel.Id;
            }

            _genreService.CreateGenre(genreNew);
            _genreService.AddGenreTranslate(genre.NameRu, "ru", genreId);

            return(Ok(genreNew));
        }
Beispiel #14
0
        public async Task <IActionResult> CreateGenre(Genre model)
        {
            var genre = await _service.CreateGenre(model);

            return(CreatedAtRoute("GenreDetails", new { id = genre.Id }, genre));
        }
Beispiel #15
0
 public ActionResult Post([FromBody] GenreViewModel genreViewModel)
 {
     _genreService.CreateGenre(genreViewModel);
     return(Ok());
 }
Beispiel #16
0
 /// <summary>
 /// Creates genre
 /// </summary>
 /// <param name="genre">genre</param>
 public void CreateGenreWithArtistName(GenreDTO genre)
 {
     genreService.CreateGenre(genre);
 }
Beispiel #17
0
        private static void TestGenreService()
        {
            List <int> list = new List <int>();

            genreService  = Container.Resolve <IGenreService>();
            clientService = Container.Resolve <IClientService>();

            //Create
            genreService.CreateGenre(new GenreDTO
            {
                Name       = "Metalcore",
                Info       = "Metalcore is a broad fusion genre of extreme metal and hardcore punk. The word is a blend of the names of the two genres. Metalcore is noted for its use of breakdowns, which are slow, intense passages that are conducive to moshing.",
                IsOfficial = true,
                CreatorID  = clientID,
            });
            genreService.CreateGenre(new GenreDTO
            {
                Name       = "Indie pop",
                Info       = "Indie pop is a subgenre of alternative rock or indie rock[1] and a subculture[2] that originated in the United Kingdom in the late 1970s. The style is inspired by punk's DIY ethic and related ideologies, and it generated a thriving fanzine, label, and club and gig circuit.",
                IsOfficial = true,
                CreatorID  = clientID
            });

            //GetGenreIdByName
            genreID = genreService.GetGenreIdByName("Metalcore");
            int indieID = genreService.GetGenreIdByName("Indie pop");

            list.Add(genreID);
            list.Add(indieID);
            Console.WriteLine(list.Count() == 2 ? "ClientService - GetGenreIdByName - OK" : "ClientService - GetGenreIdByName - FAIL");



            //GetGenreById
            GenreDTO metalcore = genreService.GetGenre(genreID);

            Console.WriteLine(metalcore.Name == "Metalcore" ? "GenreService - GetGenreById - OK" : "GenreService - GetGenreById - FAIL");

            //ListAllGenres01
            //var genres = genreService.ListAllGenres(new GenreFilter { ArtistID = artistID }, 1);
            //Console.WriteLine(genres.TotalResultCount == 1 ? "GenreService - TestListAllGenres01 - OK" : "GenreService - TestListAllGenres01 - FAIL");

            //ListAllGenres02
            var genres2 = genreService.ListAllGenres();

            Console.WriteLine(genres2.Count() == 2 ? "GenreService - ListAllGenres02 - OK" : "GenreService - ListAllGenres02 - FAIL");

            //EditGenre
            metalcore.Name = "Metal Core";
            genreService.EditGenre(metalcore);
            GenreDTO bfmvFromDB = genreService.GetGenre(metalcore.ID);

            Console.WriteLine(bfmvFromDB.Name == "Metal Core" ? "GenreService - TestEditGenre - OK" : "GenreService - TestEditGenre - FAIL");

            //DeleteGenre
            genreService.DeleteGenre(indieID);
            int violaIDFromDB = genreService.GetGenreIdByName("Viola Martinsson");

            Console.WriteLine(violaIDFromDB < 1 ? "GenreService - TestDeleteGenre - OK" : "GenreService - TestDeleteGenre - FAIL");

            //GetCreator
            ClientDTO creator = genreService.GetCreator(metalcore.ID);

            Console.WriteLine(creator.ID == clientID ? "GenreService - GetCreator - OK" : "GenreService - GetCreator - FAIL");
        }
 public async Task <IActionResult> CreateGenre(GenreDto newGenre)
 {
     return(Ok(await _genreService.CreateGenre(newGenre)));
 }
Beispiel #19
0
 public void Post([FromBody] GenreModel model)
 {
     genreService.CreateGenre(model);
 }