public NotebooksController(ApplicationDbContext context, UserManager <ApplicationUser> userManager, NotebookRepository repo) { _context = context; _repo = repo; _userManager = userManager; }
public async Task <ActionResult> Index() { var repository = new NotebookRepository(); var myNotebooks = await repository.GetNotebooks(); return(View(myNotebooks)); }
public async Task <ActionResult> Delete(string id) { var repository = new NotebookRepository(); if (id != null) { await repository.DeletePage(id); } return(Redirect("/")); }
public async Task <ActionResult> Index(string notebookid) { var repository = new NotebookRepository(); var notebook = await repository.GetNotebookSections(notebookid); ViewBag.CurrentNotebookTitle = notebook.Name; ViewBag.CurrentNotebookId = notebook.Id; return(View(notebook.Sections.OrderBy(s => s.Name).ToList())); }
public async Task <ActionResult> Index(string notebookid, string sectionid) { var repository = new NotebookRepository(); var notebook = await repository.GetNotebookPages(notebookid, sectionid); ViewBag.CurrentNotebookTitle = notebook.Name; ViewBag.CurrentNotebookId = notebook.Id; var section = notebook.Sections.First(s => s.Id == sectionid); ViewBag.CurrentSectionTitle = section.Name; return(View(section.Pages)); }
public async Task <ActionResult> Index() { // Get an access token for the request. string userObjId = AuthHelper.GetUserId(System.Security.Claims.ClaimsPrincipal.Current); SessionTokenCache tokenCache = new SessionTokenCache(userObjId, HttpContext); string authority = string.Format(ConfigurationManager.AppSettings["ida:AADInstance"], "common", "/v2.0"); AuthHelper authHelper = new AuthHelper(authority, ConfigurationManager.AppSettings["ida:AppId"], ConfigurationManager.AppSettings["ida:AppSecret"], tokenCache); string accessToken = await authHelper.GetUserAccessToken("/Notebook/Index"); // Make the request. var repository = new NotebookRepository(accessToken); var myNotebooks = await repository.GetNotebooks(); return(View(myNotebooks)); }
public async Task <ActionResult> Index(string notebookid) { // Get an access token for the request. string userObjId = System.Security.Claims.ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value; SessionTokenCache tokenCache = new SessionTokenCache(userObjId, HttpContext); string authority = string.Format(ConfigurationManager.AppSettings["ida:AADInstance"], "common", ""); AuthHelper authHelper = new AuthHelper(authority, ConfigurationManager.AppSettings["ida:AppId"], ConfigurationManager.AppSettings["ida:AppSecret"], tokenCache); string accessToken = await authHelper.GetUserAccessToken("/Section/Index"); // Make the request. var repository = new NotebookRepository(accessToken); var notebook = await repository.GetNotebookSections(notebookid); ViewBag.CurrentNotebookTitle = notebook.Name; ViewBag.CurrentNotebookId = notebook.Id; return(View(notebook.Sections.OrderBy(s => s.Name).ToList())); }
public async Task <ActionResult> Delete(string id) { // Get an access token for the request. string userObjId = AuthHelper.GetUserId(System.Security.Claims.ClaimsPrincipal.Current); SessionTokenCache tokenCache = new SessionTokenCache(userObjId, HttpContext); string authority = string.Format(ConfigurationManager.AppSettings["ida:AADInstance"], "common", "/v2.0"); AuthHelper authHelper = new AuthHelper(authority, ConfigurationManager.AppSettings["ida:AppId"], ConfigurationManager.AppSettings["ida:AppSecret"], tokenCache); string accessToken = await authHelper.GetUserAccessToken("/Page/Delete"); // Make the request. var repository = new NotebookRepository(accessToken); if (id != null) { await repository.DeletePage(id); } return(Redirect("/")); }
public async Task <ActionResult> Index(string notebookid, string sectionid) { // Get an access token for the request. string userObjId = AuthHelper.GetUserId(System.Security.Claims.ClaimsPrincipal.Current); SessionTokenCache tokenCache = new SessionTokenCache(userObjId, HttpContext); string authority = string.Format(ConfigurationManager.AppSettings["ida:AADInstance"], "common", "/v2.0"); AuthHelper authHelper = new AuthHelper(authority, ConfigurationManager.AppSettings["ida:AppId"], ConfigurationManager.AppSettings["ida:AppSecret"], tokenCache); string accessToken = await authHelper.GetUserAccessToken("/Page/Index"); // Make the request. var repository = new NotebookRepository(accessToken); var notebook = await repository.GetNotebookPages(notebookid, sectionid); ViewBag.CurrentNotebookTitle = notebook.Name; ViewBag.CurrentNotebookId = notebook.Id; var section = notebook.Sections.First(s => s.Id == sectionid); ViewBag.CurrentSectionTitle = section.Name; return(View(section.Pages)); }
public XLWorkbook Export(search materials) { Dictionary <string, List <Material> > materialDict = search.GetResult(materials); var workbook = new XLWorkbook(); foreach (var item in materialDict) { var sheetName = item.Key; switch (sheetName) { case "notebook": sheetName = "Notebooks"; break; case "display": sheetName = "Bildschirme"; break; case "book": sheetName = "Bücher"; break; case "equipment": sheetName = "Zubehör"; break; case "furniture": sheetName = "Mobiliar"; break; } if (item.Value.Count > 0) { var worksheet = workbook.Worksheets.Add(sheetName); if (sheetName.Equals("Notebooks")) { worksheet.Cell(1, 2).Value = "Marke"; worksheet.Cell(1, 3).Value = "Modell"; worksheet.Cell(1, 4).Value = "Seriennummer"; worksheet.Cell(1, 5).Value = "Vorname"; worksheet.Cell(1, 6).Value = "Nachname"; worksheet.Cell(1, 7).Value = "Räumlichkeit"; } if (sheetName.Equals("Bildschirme")) { worksheet.Cell(1, 2).Value = "Marke"; worksheet.Cell(1, 3).Value = "Modell"; worksheet.Cell(1, 4).Value = "Seriennummer"; worksheet.Cell(1, 5).Value = "Räumlichkeit"; worksheet.Cell(1, 6).Value = "Anzahl"; } if (sheetName.Equals("Bücher")) { worksheet.Cell(1, 2).Value = "Titel"; worksheet.Cell(1, 3).Value = "ISBN"; worksheet.Cell(1, 4).Value = "Vorname"; worksheet.Cell(1, 5).Value = "Nachname"; worksheet.Cell(1, 6).Value = "Räumlichkeit"; worksheet.Cell(1, 7).Value = "Anzahl"; } if (sheetName.Equals("Zubehör")) { worksheet.Cell(1, 2).Value = "Art"; worksheet.Cell(1, 3).Value = "Marke"; worksheet.Cell(1, 4).Value = "Modell"; worksheet.Cell(1, 5).Value = "Vorname"; worksheet.Cell(1, 6).Value = "Nachname"; worksheet.Cell(1, 7).Value = "Räumlichkeit"; worksheet.Cell(1, 8).Value = "Anzahl"; } if (sheetName.Equals("Mobiliar")) { worksheet.Cell(1, 2).Value = "Art"; worksheet.Cell(1, 3).Value = "Räumlichkeit"; worksheet.Cell(1, 4).Value = "Anzahl"; } for (int i = 0; i < item.Value.Count; i++) { var item1 = item.Value[i]; worksheet.Cell(1, 1).Value = "ID"; worksheet.Cell(i + 2, 1).Value = item1.id; if (item1.GetType() == typeof(notebook)) { NotebookRepository Repo = new NotebookRepository(entities); Repo.GetRelation(); var notebook = (notebook)item1; worksheet.Cell(i + 2, 2).Value = notebook.make; worksheet.Cell(i + 2, 3).Value = notebook.model; worksheet.Cell(i + 2, 4).Value = notebook.serial_number; if (notebook.person != null) { worksheet.Cell(i + 2, 5).Value = notebook.person.name1; worksheet.Cell(i + 2, 6).Value = notebook.person.name2; } if (notebook.classroom != null) { worksheet.Cell(i + 2, 7).Value = notebook.classroom.room; } worksheet.Columns().AdjustToContents(); worksheet.Rows().AdjustToContents(); } else if (item1.GetType() == typeof(display)) { DisplayRepository Repo = new DisplayRepository(entities); Repo.GetRelation(); var display = (display)item1; worksheet.Cell(i + 2, 2).Value = display.make; worksheet.Cell(i + 2, 3).Value = display.model; if (display.serial_number != null) { worksheet.Cell(i + 2, 4).Value = display.serial_number; } if (display.classroom != null) { worksheet.Cell(i + 2, 5).Value = display.classroom.room; } if (display.quantity != null) { worksheet.Cell(i + 2, 6).Value = display.quantity; } worksheet.Columns().AdjustToContents(); worksheet.Rows().AdjustToContents(); } else if (item1.GetType() == typeof(book)) { BookRepository Repo = new BookRepository(entities); Repo.GetRelation(); var book = (book)item1; worksheet.Cell(i + 2, 2).Value = book.title; worksheet.Cell(i + 2, 3).Value = book.isbn; if (book.person != null) { worksheet.Cell(i + 2, 4).Value = book.person.name1; worksheet.Cell(i + 2, 5).Value = book.person.name2; } if (book.classroom != null) { worksheet.Cell(i + 2, 6).Value = book.classroom.room; } if (book.quantity != null) { worksheet.Cell(i + 2, 7).Value = book.quantity; } worksheet.Columns().AdjustToContents(); worksheet.Rows().AdjustToContents(); } else if (item1.GetType() == typeof(equipment)) { EquipmentRepository Repo = new EquipmentRepository(entities); Repo.GetRelation(); var equipment = (equipment)item1; worksheet.Cell(i + 2, 2).Value = equipment.type; if (equipment.make != null) { worksheet.Cell(i + 2, 3).Value = equipment.make; } if (equipment.model != null) { worksheet.Cell(i + 2, 4).Value = equipment.model; } if (equipment.person != null) { worksheet.Cell(i + 2, 5).Value = equipment.person.name1; worksheet.Cell(i + 2, 6).Value = equipment.person.name2; } if (equipment.classroom != null) { worksheet.Cell(i + 2, 7).Value = equipment.classroom.room; } if (equipment.quantity != null) { worksheet.Cell(i + 2, 8).Value = equipment.quantity; } worksheet.Columns().AdjustToContents(); worksheet.Rows().AdjustToContents(); } else if (item1.GetType() == typeof(furniture)) { FurnitureRepository Repo = new FurnitureRepository(entities); Repo.GetRelation(); var furniture = (furniture)item1; worksheet.Cell(i + 2, 2).Value = furniture.type; if (furniture.classroom != null) { worksheet.Cell(i + 2, 3).Value = furniture.classroom.room; } if (furniture.quantity != null) { worksheet.Cell(i + 2, 4).Value = furniture.quantity; } worksheet.Columns().AdjustToContents(); worksheet.Rows().AdjustToContents(); } } } } return(workbook); }