public IActionResult Snimi(DirekcijeVM direkcija) { if (!ModelState.IsValid) { ViewData["gradovi"] = _context.Grad.ToList(); return(View("Dodaj", direkcija)); } Direkcija direkcije = new Direkcija { Adresa = direkcija.Adresa, GradID = direkcija.GradID }; _context.Direkcija.Add(direkcije); _context.SaveChanges(); return(RedirectToAction("Prikazi")); }
public void PokreniMotor(int stepen, Direkcija direkcija) { int pauza = 2; if (direkcija == Direkcija.Naprijed) { for (int i = 0; i < stepen; i++) { this.S1.Write(true); System.Threading.Thread.Sleep(pauza); this.S1.Write(false); this.S2.Write(true); System.Threading.Thread.Sleep(pauza); this.S2.Write(false); this.S3.Write(true); System.Threading.Thread.Sleep(pauza); this.S3.Write(false); this.S4.Write(true); System.Threading.Thread.Sleep(pauza); this.S4.Write(false); } } if (direkcija == Direkcija.Nazad) { for (int i = 0; i < stepen; i++) { this.S4.Write(true); System.Threading.Thread.Sleep(pauza); this.S4.Write(false); this.S3.Write(true); System.Threading.Thread.Sleep(pauza); this.S3.Write(false); this.S2.Write(true); System.Threading.Thread.Sleep(pauza); this.S2.Write(false); this.S1.Write(true); System.Threading.Thread.Sleep(pauza); this.S1.Write(false); } } }