public async Task <IActionResult> Create(int VoziloId, string KorisnikId, string Korisnik, string Opis) { if (ModelState.IsValid) { Komentar k1 = new Komentar { VoziloId = VoziloId, KorisnikId = KorisnikId, Korisnik = Korisnik, Opis = Opis }; db.Kometari.Add(k1); await db.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(RedirectToAction(nameof(Index))); //if (ModelState.IsValid) //{ // db.Add(komentar); // await db.SaveChangesAsync(); // return RedirectToAction(nameof(Index)); //} //return RedirectToAction(nameof(Index)); }
public async Task <IActionResult> PutAction(int id, Models.Action action) { if (id != action.Id) { return(BadRequest()); } _context.Entry(action).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ActionExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <MetaData> > CreateMeta(MetaData meta) { _context.MetaData.Add(meta); await _context.SaveChangesAsync(); return(CreatedAtAction("GetMeta", new { id = meta.Id }, meta)); }
public async Task <ActionResult <Condition> > Create(Condition condition) { _context.Condition.Add(condition); await _context.SaveChangesAsync(); return(CreatedAtAction("Get", new { id = condition.Id }, condition)); }
public async Task <ActionResult <Trigger> > CreateTrigger(Trigger trigger) { _context.Trigger.Add(trigger); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTrigger", new { id = trigger.Id }, trigger)); }
public async Task <IActionResult> Create([Bind("VoziloId,MarkaId,ModelId,TipVozilaId,KorisnikId,Kubikaza,Snaga,Kilometraza,Pogon,Menjac,BrojBrzina,Cena,Slika,SlikaTip,Opis")] Vozilo vozilo, IFormFile odabranaSlika) { if (odabranaSlika == null) { ModelState.AddModelError("FajlSlike", "Niste"); } if (ModelState.IsValid) { using (MemoryStream ms = new MemoryStream()) { await odabranaSlika.CopyToAsync(ms); vozilo.Slika = ms.ToArray(); } vozilo.SlikaTip = odabranaSlika.ContentType; db.Add(vozilo); await db.SaveChangesAsync(); return(RedirectToAction("Index", "Home")); } return(View(vozilo)); }
public async Task <IActionResult> DodajMarkuModelTip(int ModelId = 0, int MarkaId = 0, string NoviTip = "", string NovaMarkaModel = "") { if (NovaMarkaModel != " ") { NovaMarkaModel = NovaMarkaModel.First().ToString().ToUpper() + String.Join("", NovaMarkaModel.Skip(1)).ToLower(); if (MarkaId == 0) { try { Marka m1 = new Marka { Naziv = NovaMarkaModel }; db.Marke.Add(m1); await db.SaveChangesAsync(); return(RedirectToAction("Index", "Home")); } catch (Exception) { ViewBag.Greska = "Doslo je do greske prilikom cuvanja Marke"; } } if (MarkaId != 0 && ModelId == 0) { try { Modeli m1 = new Modeli { MarkaId = MarkaId, Naziv = NovaMarkaModel }; db.Models.Add(m1); await db.SaveChangesAsync(); return(RedirectToAction("Index", "Home")); } catch (Exception) { ViewBag.Greska = "Doslo je do greske prilikom cuvanja Modela"; } } } if (NoviTip != "") { NoviTip = NoviTip.First().ToString().ToUpper() + String.Join("", NoviTip.Skip(1)).ToLower(); try { TipVozila t1 = new TipVozila { Naziv = NoviTip }; db.TipoviVozila.Add(t1); await db.SaveChangesAsync(); return(RedirectToAction("Index", "Home")); } catch (Exception) { ViewBag.Greska = "Doslo je do greske prilikom cuvanja Tipa vozila"; } } return(RedirectToAction("Index", "Home")); }