public async Task <IActionResult> PutEmployeeFirms([FromRoute] int id, [FromBody] EmployeeFirms employeeFirms) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != employeeFirms.Id) { return(BadRequest()); } _context.Entry(employeeFirms).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeFirmsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutKompaniskaSmetka([FromRoute] int id, [FromBody] KompaniskaSmetka kompaniskaSmetka) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != kompaniskaSmetka.Id) { return(BadRequest()); } _context.Entry(kompaniskaSmetka).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!KompaniskaSmetkaExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutFirmiSopstvenici([FromRoute] int id, [FromBody] FirmiSopstvenici firmiSopstvenici) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != firmiSopstvenici.Id) { return(BadRequest()); } _context.Entry(firmiSopstvenici).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FirmiSopstveniciExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("Id,firstName,lastName,birthDate,Address")] Korisnik korisnik) { if (ModelState.IsValid) { _context.Add(korisnik); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(korisnik)); }
public async Task <IActionResult> Create([Bind("Id,firstName,lastName,birthDate,Position")] Employee employee) { if (ModelState.IsValid) { _context.Add(employee); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(employee)); }
public async Task <IActionResult> Create([Bind("Id,firmName,dataOsnovanje,Address")] Firma firma) { if (ModelState.IsValid) { _context.Add(firma); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(firma)); }
public async Task <IActionResult> Create([Bind("Id,bankarskiBroj,paricnaSostojba,dataIzdavanje,tip,korisnikId")] KorisnickaSmetka korisnickaSmetka) { if (ModelState.IsValid) { _context.Add(korisnickaSmetka); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["korisnikId"] = new SelectList(_context.Korisnik, "Id", "FullName", korisnickaSmetka.korisnikId); return(View(korisnickaSmetka)); }
public async Task <IActionResult> Create([Bind("Id,brojNaKarticka,tipNaKarticka,paricnaSostojba,korisnickaSmetkaId")] Karticka karticka) { if (ModelState.IsValid) { _context.Add(karticka); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["korisnickaSmetkaId"] = new SelectList(_context.KorisnickaSmetka, "Id", "bankarskiBroj", karticka.korisnickaSmetkaId); return(View(karticka)); }
public async Task <IActionResult> PutEmployee([FromRoute] int id, [FromBody] VraboteniSmetkiEdit viewmodel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != viewmodel.Vraboten.Id) { return(BadRequest()); } _context.Entry(viewmodel.Vraboten).State = EntityState.Modified; try { 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(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("Id,employeeId,kompaniskaSmetkaId,tip")] EmployeeFirms employeeFirms) { if (ModelState.IsValid) { _context.Add(employeeFirms); await _context.SaveChangesAsync(); 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> PutKorisnik([FromRoute] int id, [FromBody] KorisniciFirmiEdit model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != model.Sopstvenik.Id) { return(BadRequest()); } _context.Entry(model.Sopstvenik).State = EntityState.Modified; try { await _context.SaveChangesAsync(); IEnumerable <int> listFirmi = model.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(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
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> 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)); }