public async Task <IActionResult> Edit(int id, [Bind("ID,datumIzdavanja,KorisnikId")] Dokumentacija dokumentacija) { if (id != dokumentacija.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(dokumentacija); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DokumentacijaExists(dokumentacija.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["KorisnikId"] = new SelectList(_context.korisnici, "ID", "ID", dokumentacija.KorisnikId); return(View(dokumentacija)); }
public async Task AddDokumentAsync(Dokumentacija dokument) { using (ExtentBazaEntities _context = new ExtentBazaEntities()) { _context.Dokumentacija.Add(dokument); await _context.SaveChangesAsync(); } }
public async Task <IActionResult> Create([Bind("ID,datumIzdavanja,KorisnikId")] Dokumentacija dokumentacija) { if (ModelState.IsValid) { _context.Add(dokumentacija); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["KorisnikId"] = new SelectList(_context.korisnici, "ID", "ID", dokumentacija.KorisnikId); return(View(dokumentacija)); }
public async Task <int> UpdateDokumentAsync(Dokumentacija dokument) { using (ExtentBazaEntities _context = new ExtentBazaEntities()) { var obj = await _context.Dokumentacija.FirstOrDefaultAsync(a => a.IDDokumenta == dokument.IDDokumenta); obj.Naziv = dokument.Naziv; obj.Datum = dokument.Datum; obj.StatusDokumenta = dokument.StatusDokumenta; obj.Redosled = dokument.Redosled; obj.IDProjekta = obj.IDProjekta; return(await _context.SaveChangesAsync()); } }
private async void ShowHideDetails(object sender, System.Windows.RoutedEventArgs e) { Dokumentacija doc = DataGrid.SelectedItem as Dokumentacija; var dataProvider = new EFCoreDataProvider(); if (await dataProvider.DokumentImaPDFFajl(doc.IDDokumenta)) // Otvori taj fajl, da li je StatusDokumenta isto kao i to Da li ima pdf fajl??? za sad jeste { string filename = "temp.pdf"; File.WriteAllBytes(filename, (await dataProvider.GetPDFAsync(doc.IDDokumenta)).PDFFajl); //ovo kreira lokalni pdf fajl od bajtova System.Diagnostics.Process.Start(filename); // Otvara ga u default pdf vieweru } else // Prilozi pdf fajl { byte[] a; OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "PDF dokument | *.pdf"; if (dlg.ShowDialog() == true) { // Kreira se i prikazu progressWindows sa porukom dok se vrsi slanje dokumenta na server var progressWindow = new ProgressWindow("Upload PDF dokumenta"); progressWindow.Show(); string path = dlg.FileName.ToString(); a = File.ReadAllBytes(path); //ovo pretvara izabrani fajl u bajtove // Dodavanje novog PDF u tabelu await dataProvider.AddPDFAsync(new PDF { IDDokumenta = doc.IDDokumenta, PDFFajl = a }, Helper.TrenutniKorisnik); //Update dokumenta doc.StatusDokumenta = true; doc.Datum = DateTime.Now.ToString(); await dataProvider.UpdateDokumentAsync(doc); // ProgressWindow moze da se zatvori progressWindow.Close(); // Update podataka koji se prikazuju u dataGridu ProveriKojiDokumentiImajuUslov(); UpdateDataGrid(); } } }
public ActionResult DodajDokumentaciju(ProjektnaDokumentacijaAddVM obj) { byte[] uploadedFile = new byte[obj.File.InputStream.Length]; obj.File.InputStream.Read(uploadedFile, 0, uploadedFile.Length); var dokument = new Dokumentacija { File = uploadedFile, ProjekatId = obj.ProjekatId, Naziv = obj.File.FileName, Opis = obj.Opis, Datum = DateTime.UtcNow }; ctx.Dokumentacija.Add(dokument); ctx.SaveChanges(); return(RedirectToAction("Dokumentacija", new { id = obj.ProjekatId })); }