Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Roll,student_name")] StudentPage studentPage)
        {
            if (id != studentPage.Roll)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(studentPage);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!StudentPageExists(studentPage.Roll))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(studentPage));
        }
Ejemplo n.º 2
0
        // GET: Students
        public async Task <IActionResult> Index()
        {
            using (var context = _context)
            {
                var RouteNumbers = context.Routes.Select(x => new { Text = "Route: " + x.RouteId.ToString(), Value = x.RouteId });

                var model = new StudentPage();
                List <SelectListItem> routes = new List <SelectListItem>();
                foreach (var route in RouteNumbers)
                {
                    routes.Add(new SelectListItem {
                        Text = route.Value.ToString(), Value = route.Text
                    });
                }
                model.RouteList = new SelectList(routes, "Text", "Value");

                var studentQuery = context.Students.AsNoTracking().ToList();
                model.StudentList = studentQuery;

                var RouteStopsQuery = context.RouteStops.AsNoTracking().ToList();
                model.RouteStopsList = RouteStopsQuery;

                var RoutesQuery = context.Routes.AsNoTracking().ToList();
                model.RoutesList = RoutesQuery;

                var BusesQuery = context.Buses.AsNoTracking().ToList();
                model.BusList = BusesQuery;

                return(View(model));
            }
        }
Ejemplo n.º 3
0
        static private void LoginAdmin(Window window, StudentAccount student)
        {
            StudentPage w = new StudentPage(student);

            w.Show();
            window.Close();
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("Roll,student_name")] StudentPage studentPage)
        {
            if (ModelState.IsValid)
            {
                _context.Add(studentPage);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(studentPage));
        }
Ejemplo n.º 5
0
        public ActionResult GetStudentsOnRoute(int id)
        {
            if (id == 0)
            {
                using (var context = _context)
                {
                    var model = new StudentPage();

                    var routeStopIds = context.RouteStops.AsNoTracking()
                                       .Select(x => x.StopId)
                                       .ToList();

                    var studentList = context.Students.AsNoTracking()
                                      .Where(x => routeStopIds.Contains(x.StopId))
                                      .ToList();

                    return(Json(studentList));
                }
            }
            else
            {
                using (var context = _context)
                {
                    var model = new StudentPage();

                    var routeStopIds = context.RouteStops.AsNoTracking()
                                       .Where(x => x.RouteId == id)
                                       .Select(x => x.StopId)
                                       .ToList();

                    var studentList = context.Students.AsNoTracking()
                                      .Where(x => routeStopIds.Contains(x.StopId))
                                      .ToList();

                    model.StudentList = studentList;

                    return(Json(studentList));
                }
            }
        }
 public void BaseSetup()
 {
     // Opening the browser and navigating to the homepage
     driver      = WebDriverInstance.GetInstanceOfDriver();
     studentPage = new StudentPage(driver);
 }
Ejemplo n.º 7
0
        public async Task <HttpResponseMessage> GetStudentsAsync([FromUri] StudentFilter filter, [FromUri] StudentSort sort, [FromUri] StudentPage page)
        {
            if (filter != null && !filter.EmptyFilterString())
            {
                filter.StringToNameAndSurname();
            }
            StudentList = await studentService.ReadDataAsync(filter, sort, page);

            if (StudentList.Count() == 0)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }
            Students = mapper.Map <List <Student> >(StudentList);

            return(Request.CreateResponse(HttpStatusCode.OK, Students));
        }
Ejemplo n.º 8
0
        public async Task <List <StudentModel> > ReadDataAsync(StudentFilter filter, StudentSort sort, StudentPage page)
        {
            StudentList = await studentRepository.ReadStudentAsync(filter, sort, page);

            return(StudentList);
        }
Ejemplo n.º 9
0
 public SequentialReadScript(LoginPage login, StudentPage student, ReaderPage reader)
 {
     _login   = login;
     _student = student;
     _reader  = reader;
 }
Ejemplo n.º 10
0
 public StudentSteps(StudentPage _studentPage, DatabaseHelper _databaseHelper)
 {
     studentPage    = _studentPage;
     databaseHelper = _databaseHelper;
 }
Ejemplo n.º 11
0
        public async Task <List <StudentModel> > ReadStudentAsync(StudentFilter filter, StudentSort sort, StudentPage page)
        {
            string connectionString = @"Data Source = (LocalDB)\MSSQLLocalDB;Initial Catalog = PraksaSQL; Integrated Security = True";

            int begginingRow = 1;
            int endRow       = 11;

            if (page != null)
            {
                begginingRow = (page.PageNumber - 1) * page.PageSize;
                endRow       = begginingRow + page.PageSize + 1;
            }

            string queryString =
                "DECLARE @BegginingRow INT = " + begginingRow + ";" +
                "DECLARE @EndRow INT = " + endRow + ";";

            queryString +=
                "SELECT id,ime,prezime FROM (" +
                "SELECT ROW_NUMBER() OVER(ORDER BY id) AS RowNum, id, ime, prezime " +
                "FROM STUDENT" +
                ") AS tbl " +
                "WHERE @BegginingRow < RowNum AND @EndRow > RowNum ";


            if (filter != null)
            {
                if (!filter.EmptyFilterString())
                {
                    string FilterString = "'" + String.Join("','", filter.StudentNames) + "'";
                    queryString += "AND (ime IN (" + FilterString + ") OR (prezime IN (" + FilterString + ")))";
                }
            }

            if (sort != null)
            {
                queryString += " ORDER BY " + sort.OrderBy + " " + sort.Order;
            }
            else
            {
                queryString += " ORDER BY prezime asc";
            }

            using (SqlConnection connection =
                       new SqlConnection(connectionString))
            {
                SqlCommand command =
                    new SqlCommand(queryString, connection);
                await connection.OpenAsync();

                SqlDataReader reader = await command.ExecuteReaderAsync();

                // Call Read before accessing data.
                while (await reader.ReadAsync())
                {
                    StudentList.Add(new StudentModel {
                        id = reader.GetGuid(0), name = reader.GetString(1), surname = reader.GetString(2)
                    });
                }

                // Call Close when done reading.
                reader.Close();

                return(StudentList);
            }
        }