private bool AddVideoGame() { var videoGame = new VideoGameDto(); FillDataFromFields(videoGame, true); return(_videoGameService.Add(videoGame, out _)); }
private static void AddVideoGame(VideoGameDto videoGame, string title, decimal price, int quantityDisc, GamePlatformEnum platformEnum, StateProductEnum state) { videoGame.Title = title; videoGame.Price = price; videoGame.QuantityDisc = quantityDisc; videoGame.Platform = platformEnum; videoGame.State = state; }
private void FillDataFromFields(VideoGameDto videoGame, bool isNew) { var platform = _itemsPlatform.FirstOrDefault(x => x.Value.Equals(PlatformDropDown.SelectedValue)).Key; videoGame.Title = isNew ? TitleText.Text.RemoveMultipleSpace().ToUpperAllFirstLetter() : TitleText.Text; videoGame.Price = Convert.ToDecimal(PriceNumeric.Value); videoGame.QuantityDisc = Convert.ToInt32(QuantityNumeric.Value); videoGame.Platform = platform; var state = _changeItemsStateProduct.FirstOrDefault(valuePair => valuePair.Value.Equals(ChangeProductStateComboBox.SelectedValue)).Key; videoGame.State = state; }
private void VideoGameSelected(object sender) { switch (sender) { case Button rowButton: _videoGameSelected = (VideoGameDto)rowButton?.DataContext; break; case DataGrid rowDataGrid: _videoGameSelected = (VideoGameDto)rowDataGrid?.SelectedValue; break; } }
public void UpdateVideoGames(VideoGameDto videoGameDto) { var videoGameExist = applicationDbContext.VideoGames.Any(x => x.Id == videoGameDto.Id); if (!videoGameExist) { return; } applicationDbContext .VideoGames .Update(mapper.Map <VideoGame>(videoGameDto)); applicationDbContext.SaveChanges(); }
private bool RemoveVideoGame(VideoGameDto videoGame) { return(_videoGameService.Remove(videoGame.Id)); }
public static void LoadData() { if (!ClientService.Instance.All().Any()) { var client = new ClientDto(); AddClient(client, "40565712Z", AccreditationEnum.Dni, "Poeta Llombart", "*****@*****.**", "Alfa", "Alfacet", "666909090", DateTime.Now, StateClientEnum.Activated, false); ClientService.Instance.Add(client, out _); client = new ClientDto(); AddClient(client, "48915757R", AccreditationEnum.Dni, "Poeta Gonzalez", "*****@*****.**", "Gonzalo", "Gonzalez", "666903445", DateTime.Now, StateClientEnum.Blocked, false); ClientService.Instance.Add(client, out _); client = new ClientDto(); AddClient(client, "Z6591166S", AccreditationEnum.Nie, "Poeta Gonzalez", "*****@*****.**", "Alejandro", "Bolaño", "666234445", DateTime.Now, StateClientEnum.Leave, false); ClientService.Instance.Add(client, out _); client = new ClientDto(); AddClient(client, "Z4017538H", AccreditationEnum.Nie, "Poeta Gonzalez", "*****@*****.**", "Manuel", "Bolaño", "662234345", DateTime.Now, StateClientEnum.Leave, true); ClientService.Instance.Add(client, out _); } if (!MovieService.Instance.All().Any()) { var movie = new MovieDto(); AddMovie(movie, "La casa blanca", 3, 1, 2018, 2020, new TimeSpan( Convert.ToInt32(1), Convert.ToInt32(23), Convert.ToInt32(33)), StateProductEnum.Available); MovieService.Instance.Add(movie, out _); movie = new MovieDto(); AddMovie(movie, "La flor blanca", 20, 2, 2016, 2019, new TimeSpan( Convert.ToInt32(2), Convert.ToInt32(13), Convert.ToInt32(35)), StateProductEnum.BadState); MovieService.Instance.Add(movie, out _); movie = new MovieDto(); AddMovie(movie, "La flor blanca", 15, 3, 2017, 208, new TimeSpan( Convert.ToInt32(1), Convert.ToInt32(13), Convert.ToInt32(35)), StateProductEnum.Available); MovieService.Instance.Add(movie, out _); } if (!VideoGameService.Instance.All().Any()) { var videoGame = new VideoGameDto(); AddVideoGame(videoGame, "Tetris", 3, 2, GamePlatformEnum.Pc, StateProductEnum.Available); VideoGameService.Instance.Add(videoGame, out _); videoGame = new VideoGameDto(); AddVideoGame(videoGame, "Call of duty", 5, 3, GamePlatformEnum.Wii, StateProductEnum.Lost); VideoGameService.Instance.Add(videoGame, out _); videoGame = new VideoGameDto(); AddVideoGame(videoGame, "Need for Speed", 5, 1, GamePlatformEnum.XBox, StateProductEnum.Available); VideoGameService.Instance.Add(videoGame, out _); videoGame = new VideoGameDto(); AddVideoGame(videoGame, "Counter", 10, 1, GamePlatformEnum.XBox, StateProductEnum.Available); VideoGameService.Instance.Add(videoGame, out _); } }
public IActionResult UpdateVideoGame([FromBody] VideoGameDto videoGame) { videoGameService.UpdateVideoGames(videoGame); return(Ok()); }