public IActionResult Create(int osobaId, int certifikatId, int zanimanjeId) { if (ModelState.IsValid) { try { OsobaCertifikat osobaCert = new OsobaCertifikat(); osobaCert.CertifikatId = certifikatId; osobaCert.OsobaId = osobaId; _context.OsobaCertifikat.Add(osobaCert); _context.SaveChanges(); //logger.LogInformation($"Osoba {osoba.Ime} dodana."); // TempData[Constants.Message] = $"Osoba {} dodana."; // TempData[Constants.ErrorOccurred] = false; return(RedirectToAction("Create", "Radnik", new { osobaId, zanimanjeId })); } catch (Exception) { // logger.LogError("Pogreška prilikom dodavanje nove osobe: {0}", exc.CompleteExceptionMessage()); // ModelState.AddModelError(string.Empty, exc.CompleteExceptionMessage()); return(View()); } } else { PrepareDropDownLists(); return(View()); } }
public IActionResult Create(Natjecaj natjecaj) { if (ModelState.IsValid) { try { _context.Add(natjecaj); _context.SaveChanges(); //return RedirectToAction("Index", "Usluga"); logger.LogInformation($"Natjecaj {natjecaj.NatjecajId} dodan."); TempData[Constants.Message] = $"Natjecaj {natjecaj.NatjecajId} dodan."; TempData[Constants.ErrorOccurred] = false; return(RedirectToAction(nameof(Index))); } catch (Exception exc) { logger.LogError("Pogreška prilikom dodavanje novog natjecaja: {0}", exc.CompleteExceptionMessage()); ModelState.AddModelError(string.Empty, exc.CompleteExceptionMessage()); PrepareDropDownLists(); return(View(natjecaj)); } } else { PrepareDropDownLists(); return(View(natjecaj)); } }
public IActionResult Create(Oprema oprema) { if (ModelState.IsValid) { try { _context.Add(oprema); _context.SaveChanges(); logger.LogInformation($"oprema {oprema.Naziv} dodan."); TempData[Constants.Message] = $"Oprema {oprema.Naziv} dodan."; TempData[Constants.ErrorOccurred] = false; return(RedirectToAction(nameof(Index))); } catch (Exception exc) { logger.LogError("Pogreška prilikom dodavanje nove opreme: {0}", exc.CompleteExceptionMessage()); ModelState.AddModelError(string.Empty, exc.CompleteExceptionMessage()); return(View(oprema)); } } else { PrepareDropDownLists(); return(View(oprema)); } }
public IActionResult Create(ViewUsluga uslugaView) { if (ModelState.IsValid) { try { Usluga usluga = new Usluga(); usluga.Naziv = uslugaView.Naziv; usluga.Opis = uslugaView.Opis; usluga.KategorijaPoslaId = uslugaView.KategorijaPoslaId; _context.Add(usluga); _context.SaveChanges(); logger.LogInformation($"Usluga {usluga.UslugaId} dodan."); TempData[Constants.Message] = $"Usluga {usluga.Naziv} dodana."; TempData[Constants.ErrorOccurred] = false; return(RedirectToAction("Create", "UslugaLjudi", new { usluga.UslugaId, uslugaView.ZanimanjeId, uslugaView.ReferentniTipOpremeId })); } catch (Exception exc) { logger.LogError("Pogreška prilikom dodavanje nove usluge: {0}", exc.CompleteExceptionMessage()); ModelState.AddModelError(string.Empty, exc.CompleteExceptionMessage()); return(View()); } } else { PrepareDropDownLists(); return(View()); } }
public IActionResult Create(ViewPosao posaoView) { if (ModelState.IsValid) { try { // return RedirectToAction("Index", "Usluga"); Posao posao = new Posao(); posao.Opis = posaoView.Opis; posao.Cijena = posaoView.Cijena; posao.DodatniTrosak = posaoView.DodatniTrosak; posao.VrijemeOd = posaoView.VrijemeOd; posao.VrijemeDo = posaoView.VrijemeDo; posao.UslugaId = posaoView.UslugaId; posao.LokacijaPoslaId = posaoView.LokacijaPoslaId; _context.Add(posao); // PosaoRadnik pr = new PosaoRadnik(); // pr.PosaoId = posaoView.PosaoId; // pr.RadnikId = posaoView.RadnikId; // PosaoOprema po = new PosaoOprema(); //po.PosaoId = posaoView.PosaoId; // po.OpremaId = posaoView.OpremaId; // _context.PosaoRadnik.Add(pr); // _context.PosaoOprema.Add(po); _context.SaveChanges(); logger.LogInformation($"Posao dodan."); TempData[Constants.Message] = $"Posao dodan."; TempData[Constants.ErrorOccurred] = false; return(RedirectToAction("Create", "PosaoRadniks", new { posao.PosaoId, posaoView.KategorijaId, posaoView.OpremaId })); } catch (Exception exc) { logger.LogError("Pogreška prilikom dodavanje nove usluge: {0}", exc.CompleteExceptionMessage()); ModelState.AddModelError(string.Empty, exc.CompleteExceptionMessage()); return(View(posaoView)); } } else { PrepareDropDownLists(); return(View(posaoView)); } }
// GET: UslugaLjudi/Create public IActionResult Create(int uslugaId, int zanimanjeId, int referentniTipOpremeId) { if (ModelState.IsValid) { try { UslugaLjudi uslugaLjudi = new UslugaLjudi(); uslugaLjudi.UslugaId = uslugaId; uslugaLjudi.ZanimanjeId = zanimanjeId; _context.UslugaLjudi.Add(uslugaLjudi); _context.SaveChanges(); //logger.LogInformation($"Osoba {osoba.Ime} dodana."); // TempData[Constants.Message] = $"Osoba {} dodana."; // TempData[Constants.ErrorOccurred] = false; return(RedirectToAction("Create", "UslugaOprema", new { uslugaId, referentniTipOpremeId })); } catch (Exception) { // logger.LogError("Pogreška prilikom dodavanje nove osobe: {0}", exc.CompleteExceptionMessage()); // ModelState.AddModelError(string.Empty, exc.CompleteExceptionMessage()); return(View()); } } else { //PrepareDropDownLists(); return(View()); } }
public IActionResult Create(int osobaId, int zanimanjeId) { if (ModelState.IsValid) { try { Radnik radnik = new Radnik(); radnik.OsobaId = osobaId; radnik.KategorijaId = zanimanjeId; _context.Radnik.Add(radnik); _context.SaveChanges(); //logger.LogInformation($"Osoba {osoba.Ime} dodana."); // TempData[Constants.Message] = $"Osoba {} dodana."; // TempData[Constants.ErrorOccurred] = false; return(RedirectToAction("Index", "Osoba")); } catch (Exception) { // logger.LogError("Pogreška prilikom dodavanje nove osobe: {0}", exc.CompleteExceptionMessage()); // ModelState.AddModelError(string.Empty, exc.CompleteExceptionMessage()); return(View()); } } else { //PrepareDropDownLists(); return(View()); } }
public IActionResult Create(int posaoId, int opremaId) { if (ModelState.IsValid) { try { PosaoOprema posaoOprema = new PosaoOprema(); posaoOprema.PosaoId = posaoId; posaoOprema.OpremaId = opremaId; _context.Add(posaoOprema); _context.SaveChanges(); // logger.LogInformation($"Osoba {posaoOprema.PosaoId} dodana."); //TempData[Constants.Message] = $"Osoba {} dodana."; TempData[Constants.ErrorOccurred] = false; return(RedirectToAction("Index", "Posao")); } catch (Exception exc) { // logger.LogError("Pogreška prilikom dodavanje nove osobe: {0}", exc.CompleteExceptionMessage()); ModelState.AddModelError(string.Empty, exc.CompleteExceptionMessage()); return(View()); } } else { //PrepareDropDownLists(); return(View()); } }
public IActionResult Create(ViewOsoba osobaView) { if (ModelState.IsValid) { try { Osoba osoba = new Osoba(); osoba.Ime = osobaView.Ime; osoba.Prezime = osobaView.Prezime; osoba.GodRodjenja = osobaView.God_rodjenja; _context.Osoba.Add(osoba); OsobaCertifikat osobaCert = new OsobaCertifikat(); osobaCert.CertifikatId = osobaView.CertifikatId; osobaCert.OsobaId = osobaView.OsobaId; Radnik radnik = new Radnik(); radnik.OsobaId = osobaView.OsobaId; radnik.KategorijaId = osobaView.ZanimanjeId; _context.SaveChanges(); logger.LogInformation($"Osoba {osoba.Ime} dodana."); TempData[Constants.Message] = $"Osoba {osoba.Ime} dodana."; TempData[Constants.ErrorOccurred] = false; return(RedirectToAction("Create", "OsobaCertifikat", new { osoba.OsobaId, osobaView.CertifikatId, osobaView.ZanimanjeId })); //return RedirectToAction("Index", "Osoba"); } catch (Exception exc) { logger.LogError("Pogreška prilikom dodavanje nove osobe: {0}", exc.CompleteExceptionMessage()); ModelState.AddModelError(string.Empty, exc.CompleteExceptionMessage()); return(View()); } } else { PrepareDropDownLists(); return(View()); } }
public IActionResult Create(ViewNajam viewNajam) { if (ModelState.IsValid) { try { Najam najam = new Najam(); najam.DatumDo = viewNajam.DatumDo; najam.DatumOd = viewNajam.DatumOd; najam.FimraId = viewNajam.FimraId; najam.VrstaNajmaId = viewNajam.VrstaNajmaId; najam.Opis = viewNajam.Opis; _context.Najam.Add(najam); OpremaStavka oprStavka = new OpremaStavka(); oprStavka.NajamId = najam.NajamId; oprStavka.OpremaId = viewNajam.OpremaId; oprStavka.Kolicina = viewNajam.Kolicina; oprStavka.Cijena = viewNajam.Cijena; _context.OpremaStavka.Add(oprStavka); _context.SaveChanges(); logger.LogInformation($"Oprema {viewNajam.NajamId} dodana."); TempData[Constants.Message] = $"Oprema {viewNajam.NajamId} dodana."; TempData[Constants.ErrorOccurred] = false; return(RedirectToAction(nameof(Index))); } catch (Exception exc) { logger.LogError("Pogreška prilikom dodavanje nove opreme: {0}", exc.CompleteExceptionMessage()); ModelState.AddModelError(string.Empty, errorMessage: exc.CompleteExceptionMessage()); return(View(viewNajam)); } } else { PrepareDropDownLists(); return(View(viewNajam)); } }
public IActionResult Create(int posaoId, int kategorijaId, int opremaId) { if (ModelState.IsValid) { try { PosaoRadnik pr = new PosaoRadnik(); pr.PosaoId = posaoId; Console.WriteLine("banana" + kategorijaId); var x = _context.Radnik .AsNoTracking() .FromSql("SELECT * FROM dbo.Radnik") .Where(c => c.KategorijaId == kategorijaId) .Single(); pr.RadnikId = x.RadnikId; _context.Add(pr); _context.SaveChanges(); // return RedirectToAction("Index", "Oprema"); //logger.LogInformation($"Osoba {osoba.Ime} dodana."); // TempData[Constants.Message] = $"Osoba {} dodana."; // TempData[Constants.ErrorOccurred] = false; return(RedirectToAction("Create", "PosaoOprema", new { posaoId, opremaId })); } catch (Exception exc) { //logger.LogError("Pogreška prilikom dodavanje nove osobe: {0}", exc.CompleteExceptionMessage()); ModelState.AddModelError(string.Empty, exc.CompleteExceptionMessage()); return(View()); } } else { //PrepareDropDownLists(); return(View()); } }