public unsafe played fillContracts(played contract, List <Contract> contracts) { for (int i = 0; i < contracts.Count; i++) { contract.value[i] = contracts[i].getValue(); contract.couleur[i] = Convert.ToInt32(contracts[i].getCouleur()); contract.ids[i] = contracts[i].getPlayerId(); } return(contract); }
public unsafe played fillPile(played pile) { for (int i = 0; i < _pile.getSize(); i++) { Carte card = _pile.getElem(i); pile.value[i] = card.getValue(); pile.ids[i] = Convert.ToInt32(card.getType()); pile.couleur[i] = Convert.ToInt32(card.getCouleur()); } return(pile); }
public bool saveHistory(int user_id, string track, string album, string artist) { bool isSuccessful; if (track.Trim().Contains("&")) { track = track.Trim().Replace("&", "&"); } if (album.Trim().Contains("&")) { album = album.Trim().Replace("&", "&"); } if (artist.Trim().Contains("&")) { artist = artist.Trim().Replace("&", "&"); } try { var artistid = ((from artists in objDB.artists where artists.artist_name.Trim() == artist.Trim() select artists.artist_id)).FirstOrDefault(); int artist_id = Int16.Parse(artistid.ToString()); var albumid = ((from albums in objDB.albums where albums.album_name.Trim() == album.Trim() select albums.album_id)).FirstOrDefault(); int album_id = Int16.Parse(albumid.ToString()); var trackid = ((from tracks in objDB.tracks where tracks.track_name.Trim() == track.Trim() && tracks.album_id == album_id && tracks.artist_id == artist_id select tracks.track_id)).FirstOrDefault(); int track_id = Int16.Parse(trackid.ToString()); var query = ((from p in objDB.playeds where p.user_id == user_id && p.track_id == track_id && p.album_id == album_id && p.artist_id == artist_id select p)).FirstOrDefault(); if (query == null) { played objPlayed = new played(); objPlayed.album_id = album_id; objPlayed.artist_id = artist_id; objPlayed.track_id = track_id; objPlayed.user_id = user_id; objPlayed.played1 = DateTimeOffset.Now; objDB.playeds.Add(objPlayed); } else { query.played1 = DateTime.Now; } objDB.SaveChanges(); return(isSuccessful = true); } catch (Exception ex) { isSuccessful = false; } return(isSuccessful); }