static void Main(string[] args) { Console.WriteLine("Hello World!"); FileInfo file = new FileInfo(@"C:\Library.xlsx"); using (ExcelPackage package = new ExcelPackage(file)) { using (UnitOfWork unit = new UnitOfWork()) { // unit.Context.Database.EnsureDeleted(); // unit.Context.Database.EnsureCreated(); command dont work on this version,explore more Izdavaci.Collect(package.Workbook.Worksheets["Publishers"], unit); Console.WriteLine("Publishers seeded, pres any key to continue loading books"); Console.ReadKey(); Knjige.Collect(package.Workbook.Worksheets["Books"], unit); Console.WriteLine("Books seeded, pres any key to continue loading authors"); Console.ReadKey(); Autori.Collect(package.Workbook.Worksheets["Authors"], unit); Console.WriteLine("Authors seeded, pres any key to continue loading autorbooks"); Console.ReadKey(); AutorKnjige.Collect(package.Workbook.Worksheets["AuthBooks"], unit); } } }
public IActionResult Delete(int id) { Autori.Delete(id); Autori.Save(); return(RedirectToAction("Index")); }
public IActionResult SaveNew(AutorModel autorModel) { Autor autor = new Autor() { Ime = autorModel.Ime, Prezime = autorModel.Prezime, Email = autorModel.Email, Biografija = autorModel.Biografija }; Autori.Insert(autor); Autori.Save(); /* implement later * foreach (int knjigaId in autorModel.Knjige) * { * AutorKnjiga.Insert(new AutorKnjiga() * { * Autor = autor, * Knjiga = Knjige.Get(knjigaId) * }); * } * Save();*/ return(RedirectToAction("Index")); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Email,Telefono,Skills")] Autori autori) { if (id != autori.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(autori); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AutoriExists(autori.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(autori)); }
public ActionResult DeleteConfirmed(int id) { Autori autori = db.Autoris.Find(id); db.Autoris.Remove(autori); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,ImeIPrezime")] Autori autori) { if (ModelState.IsValid) { db.Entry(autori).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(autori)); }
public ActionResult Edit([Bind(Include = "id_autora,ime")] Autori autori) { if (ModelState.IsValid) { db.Entry(autori).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View("~/Views/Back-end/Autori/Edit.cshtml", autori)); }
public ActionResult Create([Bind(Include = "Id,ImeIPrezime")] Autori autori) { if (ModelState.IsValid) { db.Autoris.Add(autori); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(autori)); }
public ActionResult Create([Bind(Include = "id_autora,ime")] Autori autori) { if (ModelState.IsValid) { db.Autoris.Add(autori); db.SaveChanges(); return(RedirectToAction("Index")); } return(View("~/Views/Back-end/Autori/Create.cshtml", autori)); }
public async Task <IActionResult> Create([Bind("Id,Nome,Email,Telefono,Skills")] Autori autori) { if (ModelState.IsValid) { _context.Add(autori); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(autori)); }
public IActionResult Update(Autor autor) { if (autor.aId > 0) { Autori.Update(autor, autor.aId); } else { Autori.Insert(autor); } Autori.Save(); return(RedirectToAction("Index")); }
// GET: Autori/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Autori autori = db.Autoris.Find(id); if (autori == null) { return(HttpNotFound()); } return(View("~/Views/Back-end/Autori/Delete.cshtml", autori)); }
// GET: Autori/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Autori autori = db.Autoris.Find(id); if (autori == null) { return(HttpNotFound()); } return(View(autori)); }
public IActionResult Create() { List <Izdavac> izdavaci = Izdavaci.Get().ToList(); List <Autor> autori = Autori.Get().ToList(); KnjigaModel model = new KnjigaModel() { listaSvihIzdavaca = izdavaci.Select(x => new SelectListItem() { Value = x.Id.ToString(), Text = x.Ime }), listaSvihAutora = autori.Select(x => new SelectListItem() { Value = x.aId.ToString(), Text = x.Ime }) }; return(View(model)); }
public async Task BindAutore() { if (!Autori.Any()) { var autori = (await _autoriService.Get <List <Autori> >(null)).Select(a => new OdabirViewModel { Id = a.AutorId, Naziv = $"{a.Ime} {a.Prezime}" }).ToList(); Autori.Insert(0, new OdabirViewModel { Naziv = "Odaberite autora" }); OdabraniAutor = Autori.First(); foreach (var autor in autori) { Autori.Add(autor); } } }
public ActionResult RKthim(Autori model) { try { tblAutori objAutori = new tblAutori(); objAutori.AutoriEmri = model.Emri; objAutori.AutoriMbiemri = model.Mbiemri; obj._AuthorRepository.Insert(objAutori); obj.Save(); obj.Dispose(); return(RedirectToAction("Index")); //} } catch (Exception) { // Danger("Ka ndodhur nje gabim", true); return(RedirectToAction("Index")); throw; } }
public IActionResult Details(int id) { Autor autor = Autori.Get(id); return(View(autor)); }
public IActionResult Index() { List <Autor> autori = Autori.Get().ToList(); return(View(autori)); }
public IActionResult Edit(int id) { //Autor autor = ; return(View(Autori.Get(id))); }