/// <summary> /// Adds a track to a channel /// </summary> /// <param name="file"></param> /// <param name="channelId"></param> /// <param name="trackName"></param> /// <param name="artistName"></param> /// <returns></returns> public ActionResult AddTrack(HttpPostedFileBase file, int channelId, int? userId, string trackName, string artistName) { if (userId.HasValue) { try { // Verify that the user selected a file if (file != null && file.ContentLength > 0) { Stream stream = file.InputStream; MemoryStream memory = new MemoryStream(); stream.CopyTo(memory); Track track = new Track(); track.Artist = artistName; track.Name = trackName; using (RentItServiceClient proxy = new RentItServiceClient()) { proxy.AddTrack(userId.Value, channelId, memory); } } } catch (Exception) { } return Redirect(Request.UrlReferrer.PathAndQuery); } return RedirectToAction("Index", "Home"); }