Exemplo n.º 1
0
        public ActionResult Create([Bind(Include = "IdZaposlenik,Ime,Prezime,KorisnickoIme,Password")] Zaposlenik zaposlenik)
        {
            if (ModelState.IsValid)
            {
                db.Zaposlenik.Add(zaposlenik);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(zaposlenik));
        }
Exemplo n.º 2
0
        public ActionResult Create([Bind(Include = "IdSeminar,Naziv,Opis,Datum,Popunjen")] Seminar seminar)
        {
            if (ModelState.IsValid)
            {
                db.Seminar.Add(seminar);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(seminar));
        }
        public ActionResult Create([Bind(Include = "IdPredbiljezba,Datum,Ime,Prezime,Adresa,Email,Telefon,IdSeminar,Status")] Predbiljezba predbiljezba)
        {
            if (ModelState.IsValid)
            {
                predbiljezba.Datum = DateTime.Now;
                db.Predbiljezba.Add(predbiljezba);
                db.SaveChanges();
                return(RedirectToAction("Search"));
            }

            ViewBag.IdSeminar = new SelectList(db.Seminar, "IdSeminar", "Naziv", predbiljezba.IdSeminar);
            return(View(predbiljezba));
        }
        public void CourseTests_AddCourseParticipant_Success()
        {
            // Act
            using (var ctx = new SeminarDbContext())
            {
                ctx.CourseParticipants.Add(new CourseParticipant());
                ctx.SaveChanges();
            }

            // Assert
            using (var ctx = new SeminarDbContext())
            {
                Assert.AreEqual(1, ctx.CourseParticipants.Count());
            }
        }
Exemplo n.º 5
0
        public void CourseTests_AddCourse_Success()
        {
            // Act
            using (var ctx = new SeminarDbContext())
            {
                ctx.Courses.Add(new Course("Name", "Test", "Test", DateTime.Now, DateTime.Now.AddDays(1)));
                ctx.SaveChanges();
            }

            // Assert
            using (var ctx = new SeminarDbContext())
            {
                Assert.AreEqual(1, ctx.Courses.Count());
                Assert.AreEqual("Name", ctx.Courses.First().Name);
            }
        }
        public CoursesControllerTests()
        {
            // Initialize DbContext in memory
            var optionsBuilder = new DbContextOptionsBuilder();

            optionsBuilder.UseInMemoryDatabase();
            _context = new MyDbContext(optionsBuilder.Options);

            // Seed data
            _context.People.Add(new Person()
            {
                FirstName = "John",
                LastName  = "Doe"
            });
            _context.People.Add(new Person()
            {
                FirstName = "Sally",
                LastName  = "Doe"
            });
            _context.SaveChanges();

            // Create test subject
            _controller = new HomeController(_context);
        }
Exemplo n.º 7
0
 public bool AddLocation(Location location)
 {
     _dbContext.Locations.Add(location);
     return(_dbContext.SaveChanges() > 0);
 }
Exemplo n.º 8
0
 public bool AddTrack(Track track)
 {
     _dbContext.Tracks.Add(track);
     return(_dbContext.SaveChanges() > 0);
 }
Exemplo n.º 9
0
 public bool AddLevel(Level level)
 {
     _dbContext.Levels.Add(level);
     return(_dbContext.SaveChanges() > 0);
 }