Beispiel #1
0
        private static async Task RunAsyncHttpClientGenre()
        {
            bool ok = true;

            Console.WriteLine("\nWeb API Cliet - HttpClient - Genre");

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(WebApiUrl);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                // Token

                Token token = GetToken();
                if (String.IsNullOrEmpty(token.Error))
                {
                    client.DefaultRequestHeaders.Add("Authorization", String.Format("Bearer {0}", token.AccessToken));
                }

                // HTTP GET ALL

                if (ok)
                {
                    Console.WriteLine("\nGET ALL");

                    var responseGetAll = await client.GetAsync("api/genre");

                    Console.WriteLine("Status: {0}", responseGetAll.StatusCode.ToString());
                    if (responseGetAll.IsSuccessStatusCode)
                    {
                        List <GenreDTO> genres = await responseGetAll.Content.ReadAsAsync <List <GenreDTO> >();

                        foreach (GenreDTO x in genres)
                        {
                            Console.WriteLine("{0}:{1}", x.GenreId, x.Name);
                        }
                    }
                    else if (responseGetAll.StatusCode == System.Net.HttpStatusCode.BadRequest)
                    {
                        ZOperationResult operationResult = DeserializeZOperationResult(responseGetAll.Content.ReadAsStringAsync().Result);
                        Console.WriteLine(operationResult.Text);

                        Console.WriteLine(responseGetAll.Content.ToString());

                        ok = false;
                    }
                    else
                    {
                        Console.WriteLine("Status Code: " + responseGetAll.StatusCode.ToString());
                        Console.WriteLine("Content: " + responseGetAll.Content);

                        ok = false;
                    }
                }

                // HTTP GET

                if (ok)
                {
                    Console.WriteLine("\nGET");

                    var responseGet = await client.GetAsync("api/genre/1");

                    Console.WriteLine("Status: {0}", responseGet.StatusCode.ToString());
                    if (responseGet.IsSuccessStatusCode)
                    {
                        GenreDTO genreDTOGet = await responseGet.Content.ReadAsAsync <GenreDTO>();

                        Console.WriteLine("{0}:{1}", genreDTOGet.GenreId, genreDTOGet.Name);
                    }
                    else if (responseGet.StatusCode == System.Net.HttpStatusCode.BadRequest)
                    {
                        ZOperationResult operationResult = DeserializeZOperationResult(responseGet.Content.ReadAsStringAsync().Result);
                        Console.WriteLine(operationResult.Text);

                        Console.WriteLine(responseGet.Content.ToString());

                        ok = false;
                    }
                    else
                    {
                        Console.WriteLine("Status Code: " + responseGet.StatusCode.ToString());
                        Console.WriteLine("Content: " + responseGet.Content);

                        ok = false;
                    }
                }

                GenreDTO genreDTO = new GenreDTO();

                // HTTP POST

                if (ok)
                {
                    Console.WriteLine("\nPOST");

                    genreDTO = new GenreDTO()
                    {
                        GenreId = 0, Name = "Genre REST POST"
                    };
                    var responsePost = await client.PostAsJsonAsync("api/genre", genreDTO);

                    Console.WriteLine("Status: {0}", responsePost.StatusCode.ToString());
                    if (responsePost.IsSuccessStatusCode)
                    {
                        Uri uri = responsePost.Headers.Location;
                        genreDTO = responsePost.Content.ReadAsAsync <GenreDTO>().Result;

                        Console.WriteLine("{0}:{1}", genreDTO.GenreId, genreDTO.Name);
                    }
                    else if (responsePost.StatusCode == System.Net.HttpStatusCode.BadRequest)
                    {
                        ZOperationResult operationResult = DeserializeZOperationResult(responsePost.Content.ReadAsStringAsync().Result);
                        Console.WriteLine(operationResult.Text);

                        Console.WriteLine(responsePost.Content.ToString());

                        ok = false;
                    }
                    else
                    {
                        Console.WriteLine("Status Code: " + responsePost.StatusCode.ToString());
                        Console.WriteLine("Content: " + responsePost.Content);

                        ok = false;
                    }
                }

                // HTTP PUT

                if (ok)
                {
                    Console.WriteLine("\nPUT");

                    genreDTO.Name = "Genre REST PUT";

                    //var responsePut = await client.PutAsJsonAsync(uri.PathAndQuery.StringReplaceFirst("/", ""), genreDTO);
                    var responsePut = await client.PutAsJsonAsync("api/genre/" + genreDTO.GenreId.ToString(), genreDTO);

                    Console.WriteLine("Status: {0}", responsePut.StatusCode.ToString());
                    if (responsePut.IsSuccessStatusCode)
                    {
                        genreDTO = responsePut.Content.ReadAsAsync <GenreDTO>().Result;

                        Console.WriteLine("{0}:{1}", genreDTO.GenreId, genreDTO.Name);
                    }
                    else if (responsePut.StatusCode == System.Net.HttpStatusCode.BadRequest)
                    {
                        ZOperationResult operationResult = DeserializeZOperationResult(responsePut.Content.ReadAsStringAsync().Result);
                        Console.WriteLine(operationResult.Text);

                        Console.WriteLine(responsePut.Content.ToString());

                        ok = false;
                    }
                    else
                    {
                        Console.WriteLine("Status Code: " + responsePut.StatusCode.ToString());
                        Console.WriteLine("Content: " + responsePut.Content);

                        ok = false;
                    }
                }

                // HTTP DELETE

                if (ok)
                {
                    Console.WriteLine("\nDELETE");

                    //var responseDelete = await client.DeleteAsync(uri.PathAndQuery);
                    var responseDelete = await client.DeleteAsync("api/genre/" + genreDTO.GenreId.ToString());

                    Console.WriteLine("Status: {0}", responseDelete.StatusCode.ToString());
                    if (responseDelete.IsSuccessStatusCode)
                    {
                        Console.WriteLine("OK");
                    }
                    else if (responseDelete.StatusCode == System.Net.HttpStatusCode.BadRequest)
                    {
                        ZOperationResult operationResult =
                            DeserializeZOperationResult(responseDelete.Content.ReadAsStringAsync().Result);
                        Console.WriteLine(operationResult.Text);

                        Console.WriteLine(responseDelete.Content.ToString());

                        ok = false;
                    }
                    else
                    {
                        Console.WriteLine("Status Code: " + responseDelete.StatusCode.ToString());
                        Console.WriteLine("Content: " + responseDelete.Content);

                        ok = false;
                    }
                }
            }
        }
Beispiel #2
0
 public void Add(GenreDTO genreDTO)
 {
     Database.Genre.Create(_converterGenre.ConvertDTOByModel(genreDTO));
     Database.Save();
 }
Beispiel #3
0
        public MovieDTO(Movie movie)
        {
            if (movie == null)
            {
                return;
            }

            this.Id         = movie.Id;
            this.Country    = movie.Country;
            this.Title      = movie.Title;
            this.Runtime    = movie.Runtime;
            this.Poster     = movie.Poster;
            this.Trailer    = movie.Trailer;
            this.Wallpapers = movie.Wallpapers;
            this.ReleasedAt = movie.ReleasedAt;
            this.Languages  = movie.Languages;
            this.Story      = movie.Story;
            this.EndAt      = movie.EndAt;
            this.Directors  = movie.Directors;
            this.Imdb       = movie.Imdb;
            List <ScreenTypeDTO> list = new List <ScreenTypeDTO>();

            if (movie.MovieScreenTypes != null)
            {
                foreach (var movieScreenType in movie.MovieScreenTypes)
                {
                    var screenTypeDTO = new ScreenTypeDTO()
                    {
                        Id   = movieScreenType.ScreenType.Id,
                        Name = movieScreenType.ScreenType.Name,
                    };
                    list.Add(screenTypeDTO);
                }
            }
            this.ScreenTypes = list;

            List <ActorDTO> actors = new List <ActorDTO>();

            if (movie.MovieActors != null)
            {
                foreach (var movieActors in movie.MovieActors)
                {
                    var actor = new ActorDTO()
                    {
                        Id     = movieActors.Actor.Id,
                        Name   = movieActors.Actor.Name,
                        Avatar = movieActors.Actor.Avatar,
                    };
                    actors.Add(actor);
                }
            }
            this.Actors = actors;

            List <GenreDTO> genreDTOs = new List <GenreDTO>();

            if (movie.MovieGenres != null)
            {
                foreach (var movieGenre in movie.MovieGenres)
                {
                    var genre = new GenreDTO(movieGenre.Genre);
                    genreDTOs.Add(genre);
                }
            }
            this.Genres = genreDTOs;

            if (movie.Rate != null)
            {
                this.Rate = new RateDTO(movie.Rate);
            }
        }
Beispiel #4
0
 /// <summary>
 /// Makes the genre official
 /// </summary>
 /// <param name="genre">genreDTO</param>
 public void MakeOfficial(GenreDTO genreDTO)
 {
     genreDTO.IsOfficial = true;
     genreService.EditGenre(genreDTO);
 }
Beispiel #5
0
 public void EditGenre(GenreDTO genreDTO)
 {
     genreService.EditGenre(genreDTO);
 }
        private static void RunAsyncRestSharpGenre()
        {
            bool ok = true;

            Console.WriteLine("\nWeb API Client - RestSharp - Genre");

            RestClient client = new RestClient(WebApiUrl);
            //client.Authenticator = new HttpBasicAuthenticator(userName, password);

            // Token

            Token token = GetToken();

            if (String.IsNullOrEmpty(token.Error))
            {
                client.AddDefaultHeader("Authorization", String.Format("Bearer {0}", token.AccessToken));
            }

            // HTTP GET ALL

            if (ok)
            {
                Console.WriteLine("\nGET ALL");

                var requestGetAll = new RestRequest("api/genre", Method.GET)
                {
                    RequestFormat = DataFormat.Json
                };

                //var responseGetAll = client.Execute<List<Genre>>(requestGetAll); // .Data
                var responseGetAll = client.Execute(requestGetAll);
                Console.WriteLine("Status: {0}", responseGetAll.StatusCode.ToString());
                if (responseGetAll.StatusCode == HttpStatusCode.OK)
                {
                    //List<Genre> genres = responseGetAll.Data; // .Data
                    List <GenreDTO> genres = JsonConvert.DeserializeObject <List <GenreDTO> >(responseGetAll.Content);
                    foreach (GenreDTO x in genres)
                    {
                        Console.WriteLine("{0}:{1}", x.GenreId, x.Name);
                    }
                }
                else if (responseGetAll.StatusCode == System.Net.HttpStatusCode.BadRequest)
                {
                    ZOperationResult operationResult = DeserializeZOperationResult(responseGetAll.Content);
                    Console.WriteLine(operationResult.Text);

                    ok = false;
                }
                else
                {
                    Console.WriteLine("Status Code: " + responseGetAll.StatusCode.ToString());
                    Console.WriteLine("Content: " + responseGetAll.Content);

                    ok = false;
                }
            }

            // HTTP GET

            if (ok)
            {
                Console.WriteLine("\nGET");

                var requestGet = new RestRequest("api/genre/{id}", Method.GET);
                requestGet.AddUrlSegment("id", "1");

                //var responseGet = client.Execute<Genre>(requestGet); // .Data
                var responseGet = client.Execute(requestGet);
                Console.WriteLine("Status: {0}", responseGet.StatusCode.ToString());
                if (responseGet.StatusCode == HttpStatusCode.OK)
                {
                    //Genre genreGet = responseGet.Data; // .Data
                    GenreDTO genreDTOGet = JsonConvert.DeserializeObject <GenreDTO>(responseGet.Content);

                    Console.WriteLine("{0}:{1}", genreDTOGet.GenreId, genreDTOGet.Name);
                }
                else if (responseGet.StatusCode == System.Net.HttpStatusCode.BadRequest)
                {
                    ZOperationResult operationResult = DeserializeZOperationResult(responseGet.Content);
                    Console.WriteLine(operationResult.Text);

                    ok = false;
                }
                else
                {
                    Console.WriteLine("Status Code: " + responseGet.StatusCode.ToString());
                    Console.WriteLine("Content: " + responseGet.Content);

                    ok = false;
                }
            }

            GenreDTO genreDTO = new GenreDTO();

            // HTTP POST

            if (ok)
            {
                Console.WriteLine("\nPOST");

                var requestPost = new RestRequest("api/genre", Method.POST);
                requestPost.RequestFormat = DataFormat.Json;
                genreDTO = new GenreDTO()
                {
                    GenreId = 0, Name = "Genre REST POST"
                };
                requestPost.AddBody(genreDTO);

                //var responsePost = client.Execute<Genre>(requestPost); // .Data
                var responsePost = client.Execute(requestPost);
                Console.WriteLine("Status: {0}", responsePost.StatusCode.ToString());
                if (responsePost.StatusCode == System.Net.HttpStatusCode.Created)
                {
                    //genreDTO = responsePost.Data; // .Data
                    genreDTO = JsonConvert.DeserializeObject <GenreDTO>(responsePost.Content);

                    Console.WriteLine("{0}:{1}", genreDTO.GenreId, genreDTO.Name);
                }
                else if (responsePost.StatusCode == System.Net.HttpStatusCode.BadRequest)
                {
                    ZOperationResult operationResult = DeserializeZOperationResult(responsePost.Content);
                    Console.WriteLine(operationResult.Text);

                    ok = false;
                }
                else
                {
                    Console.WriteLine("Status Code: " + responsePost.StatusCode.ToString());
                    Console.WriteLine("Content: " + responsePost.Content);

                    ok = false;
                }
            }

            // HTTP PUT

            if (ok)
            {
                Console.WriteLine("\nPUT");

                genreDTO.Name = "Genre REST PUT";

                var requestPut = new RestRequest("api/genre/{genreId}", Method.PUT);
                requestPut.AddUrlSegment("genreId", genreDTO.GenreId.ToString());
                requestPut.RequestFormat = DataFormat.Json;
                requestPut.AddBody(genreDTO);

                var responsePut = client.Execute(requestPut);
                Console.WriteLine("Status: {0}", responsePut.StatusCode.ToString());
                if (responsePut.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    //genreDTO = responsePost.Data; // .Data
                    genreDTO = JsonConvert.DeserializeObject <GenreDTO>(responsePut.Content);

                    Console.WriteLine("{0}:{1}", genreDTO.GenreId, genreDTO.Name);
                }
                else if (responsePut.StatusCode == System.Net.HttpStatusCode.BadRequest)
                {
                    ZOperationResult operationResult = DeserializeZOperationResult(responsePut.Content);
                    Console.WriteLine(operationResult.Text);

                    ok = false;
                }
                else
                {
                    Console.WriteLine("Status Code: " + responsePut.StatusCode.ToString());
                    Console.WriteLine("Content: " + responsePut.Content);

                    ok = false;
                }
            }

            // HTTP DELETE

            if (ok)
            {
                Console.WriteLine("\nDELETE");

                var requestDelete = new RestRequest("api/genre/{genreId}", Method.DELETE);
                requestDelete.AddUrlSegment("genreId", genreDTO.GenreId.ToString());

                //var responseDelete = client.Execute<Genre>(requestDelete); // .Data
                var responseDelete = client.Execute(requestDelete);
                Console.WriteLine("Status: {0}", responseDelete.StatusCode.ToString());
                if (responseDelete.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    Console.WriteLine("OK");
                }
                else if (responseDelete.StatusCode == System.Net.HttpStatusCode.BadRequest)
                {
                    ZOperationResult operationResult = DeserializeZOperationResult(responseDelete.Content);
                    Console.WriteLine(operationResult.Text);

                    ok = false;
                }
                else
                {
                    Console.WriteLine("Status Code: " + responseDelete.StatusCode.ToString());
                    Console.WriteLine("Content: " + responseDelete.Content);

                    ok = false;
                }
            }
        }
 public Genre MapDTOToGenre(GenreDTO genreDTO, Genre genre)
 {
     genre.Name = genreDTO.Name;
     return(genre);
 }
 public void CreateNewGenre(GenreDTO genre)
 {
     throw new NotImplementedException();
 }
        public static UserDTO ConvertToUserDTO(this User @this)
        {
            //Выводим все жанры в List
            List <string> genreTitle = new List <string>();

            List <ResponseFilmDTO> films = new List <ResponseFilmDTO>();

            foreach (var item in @this.UserFilm)
            {
                List <GenreDTO> genres = new List <GenreDTO>();

                foreach (var itemgenre in item.Film.FilmGenre)
                {
                    genres.Add(new GenreDTO()
                    {
                        Title = itemgenre.Genre.Title
                    });
                    genreTitle.Add(itemgenre.Genre.Title);
                }

                //Заполнение модели FilmDTO
                films.Add(new ResponseFilmDTO()
                {
                    Id       = item.Film.Id,
                    Title    = item.Film.Title,
                    GenreDTO = genres
                });
            }

            //Определение, жана и как часто встречается у пользователя.
            var genreArreyString = genreTitle.ToArray();

            GenreDTO[] genreDTOs = new GenreDTO[genreTitle.Distinct().ToList().Count];
            GenreDTO   best      = new GenreDTO();

            for (int i = 0; i < genreTitle.Distinct().ToList().Count; i++)
            {
                genreDTOs[i] = new GenreDTO();
            }
            int max = 0;

            foreach (var itemArreyString in genreArreyString)
            {
                foreach (var item in genreDTOs)
                {
                    if (itemArreyString == item.Title)
                    {
                        item.Count++;
                        if (max < item.Count)
                        {
                            max        = item.Count;
                            best.Title = item.Title;
                        }
                        break;
                    }
                    else
                    {
                        if (item.Title == null)
                        {
                            item.Title = itemArreyString;
                            item.Count++;
                            if (max < item.Count)
                            {
                                max        = item.Count;
                                best.Title = item.Title;
                            }
                            break;
                        }
                    }
                }
            }
            //////////////////////////////////////////////////////////

            //Заполнение модели UserDTO
            UserDTO user = new UserDTO()
            {
                Id        = @this.Id,
                Name      = @this.Name,
                Age       = @this.Age,
                FilmsDTO  = films,
                BestGenre = best
            };

            return(user);
        }
 protected GenreCommandBase(GenreDTO entity)
 {
     Entity = entity;
 }
 public void AddGenreToMovie(GenreDTO genre)
 {
     throw new NotImplementedException();
 }
 protected GenreCommandBase(long id, GenreDTO entity)
 {
     Id     = id;
     Entity = entity;
 }
Beispiel #13
0
        static void Main(string[] args)
        {
            GenreController genresDb    = new GenreController();
            GenreDTO        genreAction = new GenreDTO()
            {
                GenreName = "Action", Description = "Dynamic action games with some logic puzzles"
            };
            GenreDTO genreSport = new GenreDTO()
            {
                GenreName = "Sprot Simulator", Description = "A sports game is a video game genre that simulates the practice of sports"
            };
            GenreDTO genreMMORPG = new GenreDTO()
            {
                GenreName = "MMORPG", Description = "Massively multiplayer online role-playing game"
            };

            //example of exeption on BL validtion
            GenreDTO badGenre = new GenreDTO()
            {
                GenreName = "MMORPG", Description = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
                                                    "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
                                                    "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
                                                    "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
                                                    "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
                                                    "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
                                                    "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
                                                    "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
                                                    "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
                                                    "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
                                                    "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
                                                    "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
                                                    "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
                                                    "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
                                                    "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
                                                    "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" +
                                                    "aaaaaaaaaaaaaaaaaaaaaa"
            };

            genresDb.Create(genreAction);
            genresDb.Create(genreSport);
            genresDb.Create(genreMMORPG);

            List <GenreDTO> allGenresFormDB = genresDb.GetAll();

            foreach (GenreDTO genre in allGenresFormDB)
            {
                Console.WriteLine($"{genre.Id} -- {genre.GenreName} : {genre.Description}");
            }

            //example of updating
            genreMMORPG.Description = "Multiplayer game";

            genresDb.Update(genreMMORPG);

            allGenresFormDB = genresDb.GetAll();
            foreach (GenreDTO genre in allGenresFormDB)
            {
                Console.WriteLine($"{genre.Id} -- {genre.GenreName} : {genre.Description}");
            }


            //Example of Deleting
            var genreToDelete = genresDb.GetById(6);

            genresDb.Delete(genreToDelete);

            allGenresFormDB = genresDb.GetAll();
            foreach (GenreDTO genre in allGenresFormDB)
            {
                Console.WriteLine($"{genre.Id} -- {genre.GenreName} : {genre.Description}");
            }

            Console.ReadKey();
        }
Beispiel #14
0
 public async Task <List <GenreDTO> > GetAllGenres()
 {
     return(GenreDTO.GetGenreDTOsFromGenre(await db.Genres.ToListAsync()));
 }
 /// <inheritdoc cref="IUpdatable{TDto}.UpdateAsync(TDto)"/>
 public async Task <GenreDTO> UpdateAsync(GenreDTO dto)
 {
     return(await _repository.UpdateAsync(dto));
 }
Beispiel #16
0
 public async Task <GenreDTO> Post([FromBody] GenreDTO value)
 {
     return(await genreService.AddGenre(value));
 }
 /* HateOs
  * Links de editar y eliminar Genres Dto*/
 private void GenerateLinks(GenreDTO genreDTO)
 {
     genreDTO.Links.Add(new Link(Url.Link("GetGenre", new { id = genreDTO.Id }), "get-genre", method: "GET"));
     genreDTO.Links.Add(new Link(Url.Link("putGenre", new { Id = genreDTO.Id }), "put-genre", method: "PUT"));
     genreDTO.Links.Add(new Link(Url.Link("deleteGenre", new { Id = genreDTO.Id }), "delete-genre", method: "DELETE"));
 }
Beispiel #18
0
 public async Task <GenreDTO> Put(int id, [FromBody] GenreDTO value)
 {
     return(await genreService.UpdateGenre(id, value));
 }
 public UpdateGenreCommand(long id, GenreDTO update) : base(id, update)
 {
 }
Beispiel #20
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");
        }
Beispiel #21
0
        public async Task <GenreDTO> Update(GenreDTO item)
        {
            Genre genre = await _database.GenreRepository.Update(_mapper.Map <GenreDTO, Genre>(item));

            return(_mapper.Map <Genre, GenreDTO>(genre));
        }
Beispiel #22
0
 public GenreReference(GenreDTO dto)
 {
     GenreName = dto.Name;
 }
Beispiel #23
0
 /// <summary>
 /// Creates genre
 /// </summary>
 /// <param name="genre">genre</param>
 public void CreateGenreWithArtistName(GenreDTO genre)
 {
     genreService.CreateGenre(genre);
 }
Beispiel #24
0
        internal GenreDTO HateoasGetAllMethodLinks(GenreDTO genreDto)
        {
            genreDto.Links.Add(UrlLink("_self", "GetGenreByIdAsync", new { id = genreDto.GenreID }));

            return(genreDto);
        }
Beispiel #25
0
        public static Genre ToEntity(this GenreDTO genre)
        {
            var config = new MapperConfiguration(cfg => cfg.CreateMap <GenreDTO, Genre>());

            return(new Mapper(config).Map <GenreDTO, Genre>(genre));
        }
Beispiel #26
0
        public IActionResult Create()
        {
            var genreDTO = new GenreDTO();

            return(View(genreDTO));
        }
Beispiel #27
0
 public void Edit(GenreDTO genreDTO)
 {
     Database.Genre.Update(_converterGenre.ConvertDTOByModel(genreDTO));
     Database.Save();
 }
Beispiel #28
0
 public Genre(GenreDTO genreDTO)
 {
     Name = genreDTO.Name;
 }
 public GenreModel ToGenreModel(GenreDTO genreDTO)
 {
     return(new GenreModel(genreDTO.Genre, genreDTO.GenreId));
 }
Beispiel #30
0
 public void Post(
     [FromBody] GenreDTO dto,
     [FromServices] ICreateGenreCommand command)
 {
     executor.ExecuteCommand(command, dto);
 }