Exemplo n.º 1
0
 public void remove(SV sv)
 {
     using (var db = new StudentDB())
     {
         db.Entry(sv).State = EntityState.Deleted;
         db.SaveChanges();
     }
 }
Exemplo n.º 2
0
 public void update(SV sv)
 {
     using (var db = new StudentDB())
     {
         db.Entry(db.SVs.Find(sv.MSSV)).CurrentValues.SetValues(sv);
         db.SaveChanges();
     }
 }
Exemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "UniID,University")] Univerisite univerisite)
 {
     if (ModelState.IsValid)
     {
         db.Entry(univerisite).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(univerisite));
 }
Exemplo n.º 4
0
 public ActionResult Edit([Bind(Include = "GenderID,Gender")] GenderInfo genderInfo)
 {
     if (ModelState.IsValid)
     {
         db.Entry(genderInfo).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(genderInfo));
 }
 public ActionResult Edit([Bind(Include = "CityID,City")] CitiesTbl citiesTbl)
 {
     if (ModelState.IsValid)
     {
         db.Entry(citiesTbl).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(citiesTbl));
 }
 public ActionResult Edit([Bind(Include = "StudentID,Firstname,Lastname,DateOfBirth,GenderID,ClassID,UniID,CityID")] SutdentTable sutdentTable)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sutdentTable).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CityID   = new SelectList(db.CitiesTbls, "CityID", "City", sutdentTable.CityID);
     ViewBag.ClassID  = new SelectList(db.ClassesTbls, "ClassID", "Class", sutdentTable.ClassID);
     ViewBag.GenderID = new SelectList(db.GenderInfoes, "GenderID", "Gender", sutdentTable.GenderID);
     ViewBag.UniID    = new SelectList(db.Univerisites, "UniID", "University", sutdentTable.UniID);
     return(View(sutdentTable));
 }
Exemplo n.º 7
0
        public IHttpActionResult RemoveStudent([FromUri] Student s)
        {
            using (StudentDB dbContext = new StudentDB())
            {
                // 1st way to delete data using LINQ query
                var student = dbContext.students
                              .Where(a => a.id == s.id)
                              .FirstOrDefault();

                // 2nd way to assign id to var type variable
                //var student = new Student { id = s.id };

                dbContext.Entry(student).State = EntityState.Deleted;

                dbContext.SaveChanges();
                return(Ok("Student Removed Successfully"));
            }
        }