private static void ImportFile(IDocumentSession session, string filePath, Book book) { var filename = Path.GetFileNameWithoutExtension(filePath); Console.WriteLine("Importing " + filename); var parts = filename.Split(new[] { " - " }, System.StringSplitOptions.None); if (parts.Length < 2) { return; } var artist = parts.First().Trim(); var name = parts.Last().Trim(); var content = File.ReadAllText(filePath); var tab = new Tab { Artist = artist, Name = name, Content = content, CreatedOn = DateTime.Now }; session.Store(tab); if (book != null) { var bookTasks = new BookService(); bookTasks.AddTabToBook(tab.Id, book.Id, session); // add song to Singalong book } }
public ActionResult Index(FormCollection collection) { var item = new Upload(); var whiteList = new string[] { "Artist", "Name", "Tab", "BookId" }; if (TryUpdateModel(item, whiteList, collection.ToValueProvider())) { if (ModelState.IsValid) { //_uploadService.Upload(item.Artist, item.Name, item.BookId, item.Tab, User.Identity.Name); var tab = new Tab { Artist = item.Artist, Name = item.Name, Content = item.Tab, CreatedOn = DateTime.UtcNow, AuthorName = User.Identity.Name }; RavenSession.Store(tab); if (item.BookId > 0) { var bookTasks = new BookService(); bookTasks.AddTabToBook(tab.Id, item.BookId.Value, RavenSession); } TempData.Add(Constants.TempDataMessage, "Upload successful, thanks!"); return RedirectToAction("Index", "Songs"); } } return View(); }
public Book Hello() { var service = new Services.BookService(); Debug.WriteLine(service.Get().First().BookName); return(service.Get().First()); }
public ActionResult AddToBook(int id, int bookId) { var bookTasks = new BookService(); bookTasks.AddTabToBook(id, bookId, RavenSession); RavenSession.SaveChanges(); TempData[Constants.TempDataMessage] = "Added to Book."; return RedirectToAction("Details", new { id = id }); }