コード例 #1
0
        public IActionResult StudentDetail(int id)
        {
            Models.TestNetCoreEFContext context = new Models.TestNetCoreEFContext();
            var entity = context.Student.FirstOrDefault(m => m.Id == id);

            return(View(entity));
        }
コード例 #2
0
        public IActionResult Add(Models.Student studentEntity)
        {
            Models.TestNetCoreEFContext context = new Models.TestNetCoreEFContext();
            context.Student.Add(studentEntity);
            context.SaveChanges();

            return(Redirect($"./StudentDetail/{studentEntity.Id}"));
        }
コード例 #3
0
        public IActionResult StudentDetail(Models.Student entity)
        {
            Models.TestNetCoreEFContext context = new Models.TestNetCoreEFContext();
            context.Entry(entity).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            context.SaveChanges();

            return(View(entity));
        }
コード例 #4
0
        public IActionResult Index()
        {
            Models.TestNetCoreEFContext context = new Models.TestNetCoreEFContext();

            var StudentList = context.Student.ToList();

            return(View(StudentList));
        }
コード例 #5
0
        public IActionResult Delete(int id)
        {
            Models.TestNetCoreEFContext context = new Models.TestNetCoreEFContext();
            var entity = context.Student.FirstOrDefault(m => m.Id == id);

            context.Student.Remove(entity);
            context.SaveChanges();

            return(Redirect("/"));
        }