Ejemplo n.º 1
0
        public void EfUpdate()
        {
            ISchoolAdministratorDal dal = new SchoolAdministratorDal("EFDAL");
            StudentDb stu    = new StudentDb();
            var       entity = stu.SchoolAdministrators.FirstOrDefault(x => x.AdministratorAccount == "1316279031");
            //entity.AdministratorPassword = "******";
            //entity.CreateAdminitratorDetialDatas.CreatedTime = DateTime.Now.AddDays(5);
            //entity.CreateAdminitratorDetialDatas.Email = "*****@*****.**";
            //entity.CreateAdminitratorDetialDatas.IsFreeze = true;
            bool isbool            = false;
            SchoolAdministrator sc = new SchoolAdministrator()
            {
                AdministratorAccount          = "1316279031",
                AdministratorPassword         = "******",
                CreateAdminitratorDetialDatas = new CreateAdminitratorDetialData()
                {
                    AdministratorAuthority = "校长",
                    CreatedTime            = DateTime.Now.Date,
                    Email    = "*****@*****.**",
                    IsFreeze = false,
                    Message  = "Heelo"
                }
            };

            Console.WriteLine(entity.AdministratorAccount);
            //isbool=dal.Update(entity);
            stu.Entry(entity).CurrentValues.SetValues(sc);
            isbool = stu.SaveChanges() > 0;
            Assert.AreEqual(isbool, true);
        }
Ejemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "StudentID,StudentName,sex,BirthDate,Height,Telephone")] Student student)
 {
     if (ModelState.IsValid)
     {
         db.Entry(student).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(student));
 }