Exemplo n.º 1
0
 public ActionResult CreateWard(Ward ward)
 {
     if (ModelState.IsValid)
     {
         ward.CreatedBy = User.Identity.Name;
         ward.CreatedDate = DateTime.Now;
         ward.UpdatedBy = User.Identity.Name;
         ward.UpdatedDate = DateTime.Now;
         ward.IsDelete = false;
         db.Entry(ward).State = System.Data.EntityState.Added;
         db.SaveChanges();
         return RedirectToAction("DistrictDetail", new { id = ward.DistrictID});
     }
     return View();
 }
Exemplo n.º 2
0
 public ActionResult EditWard(Ward ward)
 {
     if (ModelState.IsValid)
     {
         var editWard = db.Wards.Find(ward.WardID);
         editWard.UpdatedBy = User.Identity.Name;
         editWard.UpdatedDate = DateTime.Now;
         editWard.Description = ward.Description;
         editWard.DistrictID = ward.DistrictID;
         editWard.WardName = ward.WardName;
         db.Entry(editWard).State = System.Data.EntityState.Modified;
         db.SaveChanges();
         return null;
     }
     ViewBag.district = new SelectList(db.Districts.ToList(), "DistrictID", "DistrictName", ward.DistrictID);
     return View(ward);
 }