Exemple #1
0
        public ActionResult Edit([Bind(Include = "ID,DateCreated,PointOfAccessID,DeviceID")] Registration registration, string ReturnUrl, int?PersonId)
        {
            if (ModelState.IsValid)
            {
                db.Entry(registration).State = EntityState.Modified;
                db.SaveChanges();

                if (string.IsNullOrEmpty(ReturnUrl))
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(Redirect(ReturnUrl));
                }
            }

            if (PersonId == null)
            {
                ViewBag.PointOfAccessID = new SelectList(db.PointsOfAccess, "ID", "Name", registration.PointOfAccessID);
                ViewBag.DeviceID        = new SelectList(db.Devices, "ID", "TypeCode", registration.DeviceID);
            }
            else
            {
                ViewBag.PointOfAccessID = new SelectList(db.PointsOfAccess.Where(item => !item.RegisteredDevices.Any(reg => reg.Device.PersonID == PersonId)),
                                                         "ID", "Name", registration.PointOfAccessID);
                ViewBag.DeviceID = new SelectList(db.Devices.Where(item => item.PersonID == PersonId).ToList(), "ID", "TypeCode", registration.DeviceID);
            }


            return(View(registration));
        }
 public ActionResult Edit([Bind(Include = "ID,FirstName,LastName,DateOfBirth,EnrollmentDate")] Person person)
 {
     if (ModelState.IsValid)
     {
         db.Entry(person).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(person));
 }
 public ActionResult Edit([Bind(Include = "ID,Name,Location,DateCreated")] PointOfAccess pointOfAccess)
 {
     if (ModelState.IsValid)
     {
         db.Entry(pointOfAccess).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(pointOfAccess));
 }
 public ActionResult Edit([Bind(Include = "ID,DateCreated,Success,PointOfAccessID,DeviceID")] EntryLog entryLog)
 {
     if (ModelState.IsValid)
     {
         db.Entry(entryLog).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DeviceID        = new SelectList(db.Devices, "ID", "Code", entryLog.DeviceID);
     ViewBag.PointOfAccessID = new SelectList(db.PointsOfAccess, "ID", "Name", entryLog.PointOfAccessID);
     return(View(entryLog));
 }
        public ActionResult Edit([Bind(Include = "ID,Type,Code,DateCreated,PersonID")] Device device, string ReturnUrl)
        {
            if (ModelState.IsValid)
            {
                db.Entry(device).State = EntityState.Modified;
                db.SaveChanges();

                if (string.IsNullOrEmpty(ReturnUrl))
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(Redirect(ReturnUrl));
                }
            }
            ViewBag.PersonID = new SelectList(db.Persons, "ID", "FirstName", device.PersonID);

            return(View(device));
        }