public async Task <IActionResult> editSmetka(int id, EditSmetkaViewModel entry) { if (entry.Zapis.Id != id) { return(NotFound()); } var zapis = await _context.EmployeeFirms .Include(m => m.kompaniskaSmetka) .Include(m => m.vrabotenKoordinator) .FirstOrDefaultAsync(m => m.Id == id); if (zapis == null) { return(NotFound()); } if (ModelState.IsValid) { zapis.tip = entry.Zapis.tip; _context.Update(zapis); await _context.SaveChangesAsync(); } return(RedirectToAction(nameof(editSmetka))); }
public async Task <IActionResult> Edit(int id, [Bind("Id,bankarskiBroj,paricnaSostojba,dataIzdavanje,tip,korisnikId")] KorisnickaSmetka korisnickaSmetka) { if (id != korisnickaSmetka.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(korisnickaSmetka); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!KorisnickaSmetkaExists(korisnickaSmetka.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["korisnikId"] = new SelectList(_context.Korisnik, "Id", "FullName", korisnickaSmetka.korisnikId); return(View(korisnickaSmetka)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,employeeId,kompaniskaSmetkaId,tip")] EmployeeFirms employeeFirms) { if (id != employeeFirms.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(employeeFirms); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeFirmsExists(employeeFirms.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["kompaniskaSmetkaId"] = new SelectList(_context.KompaniskaSmetka, "Id", "bankarskiBroj", employeeFirms.kompaniskaSmetkaId); ViewData["employeeId"] = new SelectList(_context.Employee, "Id", "FullName", employeeFirms.employeeId); return(View(employeeFirms)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,firmName,dataOsnovanje,Address")] Firma firma) { if (id != firma.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(firma); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FirmaExists(firma.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(firma)); }
public async Task <IActionResult> Edit(int id, VraboteniSmetkiEdit viewmodel) { if (id != viewmodel.Vraboten.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(viewmodel.Vraboten); await _context.SaveChangesAsync(); IEnumerable <int> listSmetki = viewmodel.SelectedKompaniskiSmetki; IQueryable <EmployeeFirms> toBeRemoved = _context.EmployeeFirms.Where(e => !listSmetki.Contains(e.kompaniskaSmetkaId) && e.employeeId == id); _context.EmployeeFirms.RemoveRange(toBeRemoved); IEnumerable <int> existSmetki = _context.EmployeeFirms.Where(e => listSmetki.Contains(e.kompaniskaSmetkaId) && e.employeeId == id).Select(e => e.kompaniskaSmetkaId); IEnumerable <int> newSmetki = listSmetki.Where(s => !existSmetki.Contains(s)); foreach (int smetkaId in newSmetki) { _context.EmployeeFirms.Add(new EmployeeFirms { employeeId = id, kompaniskaSmetkaId = smetkaId }); } await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(viewmodel.Vraboten.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(viewmodel)); }
public async Task <IActionResult> Edit(int id, KorisniciFirmiEdit viewmodel) { if (id != viewmodel.Sopstvenik.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(viewmodel.Sopstvenik); await _context.SaveChangesAsync(); IEnumerable <int> listFirmi = viewmodel.SelectedFirmi; IQueryable <FirmiSopstvenici> toBeRemoved = _context.FirmiSopstvenici.Where(s => !listFirmi.Contains(s.firmaId) && s.sopstvenikId == id); _context.FirmiSopstvenici.RemoveRange(toBeRemoved); IEnumerable <int> existFirmi = _context.FirmiSopstvenici.Where(s => listFirmi.Contains(s.firmaId) && s.sopstvenikId == id).Select(s => s.firmaId); IEnumerable <int> newFirmi = listFirmi.Where(e => !existFirmi.Contains(e)); foreach (int firmId in newFirmi) { _context.FirmiSopstvenici.Add(new FirmiSopstvenici { firmaId = firmId, sopstvenikId = id }); } await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!KorisnikExists(viewmodel.Sopstvenik.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(viewmodel)); }
public async Task <IActionResult> dodadiSredstva(int?id, KorisnikSmetkiViewModel entry) { // KorisnickaSmetka input = entry.Smetka; if (id != entry.Smetka.Id) { return(NotFound()); } if (ModelState.IsValid) { await _context.SaveChangesAsync(); _context.Update(entry.Smetka); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(entry)); }