コード例 #1
0
 public static void CreateNew(studentModel student)
 {
     using (IDbConnection cnn = new SqlConnection("Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=rockBottomHigh_DB;Integrated Security=True;Connect Timeout=60;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"))
     {
         cnn.Query <studentModel>("insert into students (fname, lname, dateOfEnrollment, age, grade, GPA) values(@fname, @lname, @dateOfEnrollment, @age, @grade, @GPA)", student);
     }
 }
コード例 #2
0
 public static void Update(studentModel student)
 {
     using (IDbConnection cnn = new SqlConnection("Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=rockBottomHigh_DB;Integrated Security=True;Connect Timeout=60;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"))
     {
         cnn.Query <studentModel>("update students set fname=(@fname), lname=(@lname), dateOfEnrollment=(@dateOfEnrollment), age=(@age), grade=(@grade), GPA=(@GPA) where StudentId=(@StudentId)", student);
     }
 }
コード例 #3
0
        public List <studentModel> GetListDelete()
        {
            List <studentModel> list = new List <studentModel>();
            var    sqlConnection     = SQLiteConnect.CreateInstance().SQLiteConnection;
            String querry            = "select * from Student_2 where status=0";

            using (var result = sqlConnection.Prepare(querry))
            {
                while (SQLiteResult.ROW == result.Step())
                {
                    String rollNumber = result["rollNumber"].ToString();
                    String name       = (string)result["name"];
                    String status     = result["status"].ToString();;

                    var student = new studentModel()
                    {
                        rollNumber = Convert.ToInt32(rollNumber),
                        name       = name,
                        status     = Convert.ToInt32(status),
                    };
                    list.Add(student);
                }
            }
            return(list);
        }
コード例 #4
0
        //  [ResponseType(typeof(student))]
        public IHttpActionResult Deletestudent(int id)
        {
            studentModel studentModell = this._istudentrepository.Getstudent(id);

            if (studentModell == null)
            {
                return(NotFound());
            }


            this._istudentrepository.Deletestudent(id);
            return(Ok());
        }
コード例 #5
0
        public bool Save(studentModel student)
        {
            var sqlConnection = SQLiteConnect.CreateInstance().SQLiteConnection;
            var querry        = "insert into Student_2 (rollNumber, name, status) values (?,?,?)";

            using (var stt = sqlConnection.Prepare(querry))
            {
                stt.Bind(1, student.rollNumber);
                stt.Bind(2, student.name);
                stt.Bind(3, student.status);
                var result = stt.Step();
                Debug.WriteLine("result=" + result);
                return(true);
            }
        }
コード例 #6
0
        public void Putstudent(studentModel studentModell)
        {
            student student = new student();

            student.id                   = studentModell.id;
            student.ime                  = studentModell.ime;
            student.br_indexa            = studentModell.br_indexa;
            student.datum_rodjenja       = studentModell.datum_rodjenja;
            student.jmbg                 = studentModell.jmbg;
            student.prezime              = studentModell.prezime;
            student.srednje_ime          = studentModell.srednje_ime;
            student.studentcol           = studentModell.studentcol;
            context.Entry(student).State = EntityState.Modified;
            base.SaveChanges();
        }
コード例 #7
0
        public void Poststudent(studentModel studentModell)
        {
            student student = new student();

            student.id             = studentModell.id;
            student.ime            = studentModell.ime;
            student.br_indexa      = studentModell.br_indexa;
            student.datum_rodjenja = studentModell.datum_rodjenja;
            student.jmbg           = studentModell.jmbg;
            student.prezime        = studentModell.prezime;
            student.srednje_ime    = studentModell.srednje_ime;
            student.studentcol     = studentModell.studentcol;
            context.student.Add(student);
            base.SaveChanges();
        }
コード例 #8
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            int    student_roll = Convert.ToInt32(txt_rollNumber.Text);
            String student_name = txt_name.Text;

            studentModel student = new studentModel()
            {
                rollNumber = Convert.ToInt32(student_roll),
                name       = student_name,
                status     = 1,
            };
            bool result = service.Save(student);

            if (result == true)
            {
                txt_result.Text = "SUCESS";
            }
        }
コード例 #9
0
        public IHttpActionResult Poststudent([FromBody] student student)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            studentModel studentModell = new studentModel();

            studentModell.id             = student.id;
            studentModell.ime            = student.ime;
            studentModell.br_indexa      = student.br_indexa;
            studentModell.datum_rodjenja = student.datum_rodjenja;
            studentModell.jmbg           = student.jmbg;
            studentModell.prezime        = student.prezime;
            studentModell.srednje_ime    = student.srednje_ime;
            studentModell.studentcol     = student.studentcol;
            this._istudentrepository.Poststudent(studentModell);
            return(Ok());
        }
コード例 #10
0
        // [ResponseType(typeof(student))]
        public IHttpActionResult Getstudent([FromUri] int id)
        {
            studentModel studentModell = this._istudentrepository.Getstudent(id);

            if (studentModell == null)
            {
                return(NotFound());
            }
            else
            {
                student student = new student();
                student.id             = studentModell.id;
                student.ime            = studentModell.ime;
                student.br_indexa      = studentModell.br_indexa;
                student.datum_rodjenja = studentModell.datum_rodjenja;
                student.jmbg           = studentModell.jmbg;
                student.prezime        = studentModell.prezime;
                student.srednje_ime    = studentModell.srednje_ime;
                student.studentcol     = studentModell.studentcol;
                return(Ok(student));
            }
        }
コード例 #11
0
        public studentModel Getstudent(int id)
        {
            studentModel studentModell = new studentModel();
            student      student       = context.student.Find(id);

            if (student == null)
            {
                return(null);
            }
            else
            {
                studentModell.br_indexa      = student.br_indexa;
                studentModell.datum_rodjenja = student.datum_rodjenja;
                studentModell.id             = student.id;
                studentModell.ime            = student.ime;
                studentModell.prezime        = student.prezime;
                studentModell.jmbg           = student.jmbg;
                studentModell.srednje_ime    = student.srednje_ime;
                studentModell.studentcol     = student.studentcol;
                return(studentModell);
            }
        }
コード例 #12
0
        public List <studentModel> Get()
        {
            var profesori = context.student.ToList();

            List <studentModel> ListaStudenata = new List <studentModel>();

            foreach (var profa in profesori)
            {
                studentModel model = new studentModel();

                model.id             = profa.id;
                model.ime            = profa.ime;
                model.srednje_ime    = profa.srednje_ime;
                model.datum_rodjenja = profa.datum_rodjenja;
                model.br_indexa      = profa.br_indexa;
                model.jmbg           = profa.jmbg;
                model.prezime        = profa.prezime;
                model.studentcol     = profa.studentcol;
                ListaStudenata.Add(model);
            }
            return(ListaStudenata);
        }
コード例 #13
0
 public IActionResult StudentCreate(studentModel m)
 {
     StudentDataAccess.CreateNew(m);
     return(RedirectToAction("Index"));
 }
コード例 #14
0
 public IActionResult UpdateStudent(studentModel m)
 {
     StudentDataAccess.Update(m);
     return(RedirectToAction("Index"));
 }
コード例 #15
0
 public bool Save(studentModel student)
 {
     return(studentdao.Save(student));
 }