public void CanUpdateCurrency() { var x = new Vinyl("bertram","herbert",33,25,23.90m,Currency.EUR); x.UpdatePrice (234m, Currency.USD); Assert.IsTrue(x.actualprice.Unit!=Currency.EUR); Assert.IsTrue(x.actualprice.Unit==Currency.USD); }
public override Midia InsertMidia(MidiaType midia_type, string nome_album) { Midia new_album = new Vinyl(nome_album); string sql = "INSERT INTO VINYL (nome_album) " + "VALUES (@Nome_Album)"; SqlCommand cmd = new SqlCommand(sql, SqlDbConnection.getConnection()); cmd.Parameters.AddWithValue("@Nome_Album", nome_album); cmd.CommandType = CommandType.Text; SqlDbConnection.cn.Open(); try { int i = cmd.ExecuteNonQuery(); if (i > 0) { Console.WriteLine("Registro incluido com sucesso!"); } } catch (Exception ex) { Console.WriteLine("Erro: " + ex.ToString()); } finally { SqlDbConnection.cn.Close(); } return(new_album); }
public async Task <IActionResult> OnPostAsync(string[] selectedCategories) { var newVinyl = new Vinyl(); if (selectedCategories != null) { newVinyl.VinylCategories = new List <VinylCategory>(); foreach (var cat in selectedCategories) { var catToAdd = new VinylCategory { CategoryID = int.Parse(cat) }; newVinyl.VinylCategories.Add(catToAdd); } } if (await TryUpdateModelAsync <Vinyl>( newVinyl, "Vinyl", i => i.Album, i => i.Artist, i => i.Price, i => i.PublishingDate, i => i.ColorID)) { _context.Vinyl.Add(newVinyl); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } PopulateAssignedCategoryData(_context, newVinyl); return(Page()); }
public JsonResult SaveVinyl([FromBody] Vinyl model) { JSONObjectResult result = new JSONObjectResult { Status = System.Net.HttpStatusCode.OK }; try { if (model == null) { throw new Exception("There is an error ocurred trying to save a vinyl"); } model.Id_VinylFormat = 1; result.Data = _vinylService.SaveVinyl(model); } catch (Exception e) { result.Status = System.Net.HttpStatusCode.BadRequest; result.Errors.Add(e.Message); } return(new JsonResult(result)); }
public void GetTitle_ReturnsTitleOfVinyl_String() { string title = "Abbey Road"; Vinyl newVinyl = new Vinyl(title); string result = newVinyl.Title; Assert.AreEqual(title, result); }
public void Find_ReturnsInstanceOfVinylWithThatId_Vinyl() { Vinyl newVinyl = new Vinyl("title"); Vinyl newVinyl2 = new Vinyl("title"); Vinyl result = Vinyl.Find(1); Assert.AreEqual(newVinyl, result); }
void OnCollisionEnter(Collision c) { Vinyl v = c.collider.gameObject.GetComponent <Vinyl>(); if (v != null && m_currentVinyl == null && !v.IsAttached()) { PlayNewVinyl(v); } }
public async Task <IActionResult> AddToUserWantlist(string spotifyAlbumId) { //requete par id de l'album pour avoir les données complètes à sauver dans la table string queryString = "https://api.spotify.com/v1/albums/" + spotifyAlbumId; using (var client = new HttpClient()) using (var request = new HttpRequestMessage()) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", await _userService.RefreshToken()); request.Method = HttpMethod.Get; request.RequestUri = new Uri(queryString); var output = await client.SendAsync(request); //on récupère le json de spotify var result = await output.Content.ReadAsAsync <AlbumIdSearchResultJsonModel>(); //on vérifie si c'est pas vide if (result != null) { Vinyl vinyl = new Vinyl() { AlbumName = result.name, ReleaseYear = result.release_date, ArtistName = result.artists[0].name, ImageUrl = result.images[0].url, Label = result.label, SpotifyAlbumId = spotifyAlbumId, //todo : recupérer les tracks via methode TrackList = _spotifyService.GetTracks(result), Genres = await _spotifyService.GetGenres(result) }; //on insère le vinyl dans la db _vinylRepo.Insert(vinyl); //on met à jour la wantlist du user var currentUser = await _userManager.GetUserAsync(User); var wantlist = new Wantlist() { UserId = currentUser.Id, VinylId = vinyl.Id }; //on insère dans la db _listRepositoryAccessor("Wantlist").Insert(wantlist); //succès et redirection vers la collection mise à jour TempData["SuccessMessage"] = "Vinyl added successfully"; return(RedirectToAction("DisplayMyWantlist")); } //échec et redirection vers la collection non mise à jour TempData["ErrorMessage"] = "Vinyl not added, something went wrong"; return(RedirectToAction("DisplayMyWantlist")); } }
public ActionResult DeleteConfirmed(int id) { Vinyl vinyl = db.Vinyls.Find(id); // db.Entry(vinyl).State = EntityState.Modified; db.Vinyls.Remove(vinyl); db.SaveChanges(); return(RedirectToAction("Index")); }
public static IOrder Map(OrderDTO orderDTO) { Client client = new Client(orderDTO.ClientID, orderDTO.ClientName, orderDTO.ClientAddress); Vinyl vinyl = new Vinyl(orderDTO.VinylID, orderDTO.VinylTitle, orderDTO.VinylBand, orderDTO.VinylPrice, 0); Order order = new Order(orderDTO.ID, client, vinyl); return(order); }
public void GetTest() { Vinyl vinyl = new Vinyl(); var request = _vinylsDb.Vinyl.Include(i => i.Genre).AsEnumerable(); Assert.Equals(vinyl, request); }
public ActionResult Delete(int?id) { Vinyl vinyl = db.Vinyls.Find(id); if (vinyl == null) { return(HttpNotFound()); } return(View(vinyl)); }
public IActionResult Delete(int vinylId) { Vinyl deletedVinyl = vinylRepository.DeleteVinyl(vinylId); if (deletedVinyl != null) { TempData["message"] = $"{deletedVinyl} was deleted"; } return(RedirectToAction("Index")); }
public ActionResult Edit(Vinyl vinyl) { if (ModelState.IsValid) { db.Entry(vinyl).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(vinyl)); }
public IActionResult OnGet() { ViewData["ColorID"] = new SelectList(_context.Set <Color>(), "ID", "ColorName"); var vinyl = new Vinyl(); vinyl.VinylCategories = new List <VinylCategory>(); PopulateAssignedCategoryData(_context, vinyl); return(Page()); }
public void GetAll_ReturnsListOfVinyls_List() { Vinyl newVinyl = new Vinyl("title"); Vinyl newVinyl2 = new Vinyl("title"); List <Vinyl> newList = new List <Vinyl> { newVinyl, newVinyl2 }; List <Vinyl> result = Vinyl.GetAll(); CollectionAssert.AreEqual(newList, result); }
public ActionResult AddArtist(Vinyl vinyl, int ArtistId) { if (ArtistId != 0) { _db.ArtistVinyl.Add(new ArtistVinyl() { ArtistId = ArtistId, VinylId = vinyl.VinylId }); } _db.SaveChanges(); return(RedirectToAction("Index")); }
protected override void Update() { base.Update(); if (m_currentVinyl != null && m_currentVinyl.IsAttached()) { m_audioSource.Stop(); m_audioSource.clip = null; m_currentVinyl.GetComponent <Collider>().isTrigger = false; m_currentVinyl = null; } }
public static VinylDTO Map(Vinyl vinyl) { VinylDTO vinylDTO = new VinylDTO() { ID = vinyl.ID, Title = vinyl.Title, Band = vinyl.Band, Price = vinyl.Price, inStock = vinyl.InStock }; return(vinylDTO); }
public ActionResult Edit(Vinyl vinyl, int ArtistId) { if (ArtistId != 0) { _db.ArtistVinyl.Add(new ArtistVinyl() { ArtistId = ArtistId, VinylId = vinyl.VinylId }); } _db.Entry(vinyl).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public List <Vinyl> GetMyWantlist(string userId) { var wantlistTable = _listRepositoryAccessor("Wantlist").GetAllWantlists(); var userVinylList = wantlistTable.Where(u => u.UserId == userId).ToList(); var vinylList = new List <Vinyl>(); foreach (var userVinyl in userVinylList) { Vinyl vinyl = _vinylRepo.GetById(userVinyl.VinylId.ToString()); vinylList.Add(vinyl); } return(vinylList); }
public IActionResult Edit(Vinyl vinyl) { if (ModelState.IsValid) { vinylRepository.SaveVinyl(vinyl); TempData["message"] = $"{vinyl.Album.AlbumName} has been saved"; return(RedirectToAction("Index")); } else { return(View(vinyl)); } }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Vinyl vinyl = db.Vinyls.Find(id); if (vinyl == null) { return(HttpNotFound()); } return(View(vinyl)); }
public void CannotAddEmptyDiskname() { Assert.Catch (() => { var x = new Vinyl ("bertram", "", 33, 25, 23.90m, Currency.EUR); }); try{ var x = new Vinyl("bertram","",33,25,23.90m,Currency.EUR); } catch{ Assert.Fail (); } }
public ActionResult Create(Vinyl vinyl, Artist artist, int ArtistId) { _db.Vinyls.Add(vinyl); _db.Artists.Add(artist); if (ArtistId != 0) { _db.ArtistVinyl.Add(new ArtistVinyl() { ArtistId = ArtistId, VinylId = vinyl.VinylId }); } _db.SaveChanges(); return(RedirectToAction("Index")); }
public void CannotAddNegativePrice() { Assert.Catch (() => { var x = new Vinyl ("bertram", "herbert", 33, 25, -23.90m, Currency.EUR); }); try{ var x = new Vinyl("bertram","herbert",33,25,-23.90m,Currency.EUR); } catch{ Assert.Fail (); } }
public void CannotAddEmptyBandname() { Assert.Catch (() => { var x = new Vinyl ("", "herbert", 33, 25, 23.90m, Currency.EUR); }); try{ var x = new Vinyl("","herbert",33,25,23.90m,Currency.EUR); } catch{ Assert.Fail (); } }
private void PlayNewVinyl(Vinyl v) { m_audioSource.Stop(); m_audioSource.clip = v.m_clip; m_audioSource.Play(); v.GetComponent <Collider>().isTrigger = true; v.GetComponent <Rigidbody>().isKinematic = true; v.transform.SetParent(transform); v.transform.position = m_VinylSnapTransform.position; v.transform.rotation = m_VinylSnapTransform.rotation; m_currentVinyl = v; }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Vinyl = await _context.Vinyl.FirstOrDefaultAsync(m => m.ID == id); if (Vinyl == null) { return(NotFound()); } return(Page()); }
public List <Vinyl> GetMyCollection(string userId) { var vinylForSaleTable = _listRepositoryAccessor("VinylForSale").GetAllVinylsForSale(); var collectionList = vinylForSaleTable.Where(u => u.UserId == userId).ToList(); var vinylList = new List <Vinyl>(); foreach (var collection in collectionList) { Vinyl vinyl = _vinylRepo.GetById(collection.VinylId.ToString()); if (vinyl != null) { vinylList.Add(vinyl); } } return(vinylList); }
public ActionResult Save(Vinyl vinyl, HttpPostedFileBase postedImage, HttpPostedFileBase postedAudio) { // Validation: If the model is not valid maintain the specific view if (!ModelState.IsValid) { var viewModel = new VinylFormViewModel() { Vinyl = vinyl, Categories = context.Categories.ToList(), Genres = context.Genres.ToList(), RecordLabels = context.RecordLabels.ToList(), //ContentFiles = context.ContentFiles.ToList() }; return(View("VinylForm", viewModel)); } // Create if (vinyl.Id == 0) { context.Vinyls.Add(vinyl); } // Edit else { var vinylInDb = context.Vinyls.Single(v => v.Id == vinyl.Id); // properties from base model Product vinylInDb.Price = vinyl.Price; vinylInDb.Quantity = vinyl.Quantity; vinylInDb.IsAvailable = vinyl.IsAvailable; //vinylInDb.CategoryId = vinyl.CategoryId; // categories are constants //vinylInDb.ContentFiles = vinyl.ContentFiles; //vinylInDb.OrderDetails = vinyl.OrderDetails; // properties from derived model Vinyl //vinylInDb.Artist = vinyl.Artist; //vinylInDb.Title = vinyl.Title; //vinylInDb.ReleaseDate = vinyl.ReleaseDate; //vinylInDb.GenreId = vinyl.GenreId; //vinylInDb.RecordLabelId = vinyl.RecordLabelId; //vinylInDb.Formats = vinyl.Formats; } context.SaveChanges(); return(RedirectToAction("Index", "Vinyls")); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Vinyl = await _context.Vinyl.FindAsync(id); if (Vinyl != null) { _context.Vinyl.Remove(Vinyl); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task OnGetAsync(int?id, int?categoryID) { VinylD = new VinylData(); VinylD.VinylRecords = await _context.Vinyl .Include(b => b.Color) .Include(b => b.VinylCategories) .ThenInclude(b => b.Category) .AsNoTracking() .OrderBy(b => b.Album) .ToListAsync(); if (id != null) { VinylID = id.Value; Vinyl vinyl = VinylD.VinylRecords .Where(i => i.ID == id.Value).Single(); VinylD.Categories = vinyl.VinylCategories.Select(s => s.Category); } }
static void Main(string[] args) { var stopwatch = new Stopwatch(); stopwatch.Start(); var vinyl = new Vinyl(args[0]); byte[] res; if (args.Length < 2) { res = Vinyl.ExtractAudioBytes(vinyl); } else { res = Vinyl.ExtractAudioBytes(vinyl, Vinyl.ExtractionOptions.SaveTrack); } stopwatch.Stop(); Console.WriteLine("Center of this plate:\t{0}", vinyl.Center); Console.WriteLine("Average width of one track:\t{0:f3}", vinyl.TrackWidth); Console.WriteLine("Average width of one gap:\t{0:f3}", vinyl.GapWidth); Console.WriteLine("Approximate count of spins:\t{0}", vinyl.SpinCount); Console.WriteLine("Approximate duration:\t{0}", vinyl.Duration); Console.WriteLine("\nAll computations took {0} ms.", stopwatch.ElapsedMilliseconds); var outputFilename = String.Format("{0}.wav", args[0]); using (var writer = new WavPcmWriter(res.Length / vinyl.Duration.Seconds, 8, 1, outputFilename)) { writer.Write(res, 0); } var play = new Microsoft.VisualBasic.Devices.Audio(); play.Play(outputFilename, Microsoft.VisualBasic.AudioPlayMode.WaitToComplete); }
public void CanUpdatePrice() { var x = new Vinyl("bertram","herbert",33,25,23.90m,Currency.EUR); x.UpdatePrice (234m, Currency.EUR); Assert.IsTrue(x.actualprice.Amount!=23.90m); }