public ActionResult Create([Bind(Include = "ID,Type,Code,DateCreated,PersonID")] Device device, string ReturnUrl, int?PersonId) { if (ModelState.IsValid) { db.Devices.Add(device); db.SaveChanges(); if (string.IsNullOrEmpty(ReturnUrl)) { return(RedirectToAction("Index")); } else { return(Redirect(ReturnUrl)); } } if (PersonId == null) { ViewBag.PersonID = new SelectList(db.Persons, "ID", "FirstNameLastName"); } else { ViewBag.PersonID = new SelectList(db.Persons.Where(item => item.ID == PersonId), "ID", "FirstNameLastName"); } return(View(device)); }
public ActionResult Create([Bind(Include = "ID,FirstName,LastName,DateOfBirth,EnrollmentDate")] Person person) { if (ModelState.IsValid) { db.Persons.Add(person); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(person)); }
public ActionResult Create([Bind(Include = "ID,Name,Location,DateCreated")] PointOfAccess pointOfAccess) { if (ModelState.IsValid) { db.PointsOfAccess.Add(pointOfAccess); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(pointOfAccess)); }
public ActionResult Create([Bind(Include = "ID,DateCreated,Success,PointOfAccessID,DeviceID")] EntryLog entryLog) { if (ModelState.IsValid) { db.EntryLogs.Add(entryLog); 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 string GetAccess(string PoiId, string Code) { try { int _PoiId = Int32.Parse(PoiId); var poi = db.PointsOfAccess.FirstOrDefault(item => item.ID == _PoiId); var device = db.Devices.FirstOrDefault(item => item.Code == Code); var success = poi.RegisteredDevices.FirstOrDefault(reg => reg.Device.Code == Code) != null; var entryLog = new EntryLog { DateCreated = DateTime.Now, DeviceID = device.ID, PointOfAccessID = poi.ID, Success = success }; db.EntryLogs.Add(entryLog); db.SaveChanges(); if (success) { return("TRUE"); } else { return("FALSE"); } } catch (Exception e) { return("EXCEPTION"); } }
public ActionResult Create([Bind(Include = "ID,DateCreated,PointOfAccessID,DeviceID")] Registration registration, string ReturnUrl, int?PersonId) { if (ModelState.IsValid) { db.Registrations.Add(registration); db.SaveChanges(); if (string.IsNullOrEmpty(ReturnUrl)) { return(RedirectToAction("Index")); } else { return(Redirect(ReturnUrl)); } } PopulateSelectList(ViewBag, PersonId, registration); return(View(registration)); }
public void Post([FromBody] Identity value) { db.Identitiets.Add(value); db.SaveChanges(); }
public void Post([FromBody] AccessLogEntry value) { db.AccessLogEntries.Add(value); db.SaveChanges(); }
public void Post([FromBody] Item value) { db.Items.Add(value); db.SaveChanges(); }
protected override void Seed(AccessControlContext context) { var persons = new List <Person> { new Person { FirstName = "Riste", LastName = "Poposki", DateOfBirth = DateTime.Parse("2018-09-17"), EnrollmentDate = DateTime.Now }, new Person { FirstName = "Monkas", LastName = "Noob", DateOfBirth = DateTime.Parse("2018-06-01"), EnrollmentDate = DateTime.Now } }; persons.ForEach(s => context.Persons.Add(s)); context.SaveChanges(); var devices = new List <Device> { new Device { Type = DeviceType.Card, Code = "12345678", DateCreated = DateTime.Now, PersonID = 1 }, new Device { Type = DeviceType.KeyPadCode, Code = "1234", DateCreated = DateTime.Now, PersonID = 2 } }; devices.ForEach(s => context.Devices.Add(s)); context.SaveChanges(); var pointOfAccess = new List <PointOfAccess> { new PointOfAccess { Name = "DomaVrata", Location = "Skopje", DateCreated = DateTime.Now, }, new PointOfAccess { Name = "Garaza", Location = "Struga", DateCreated = DateTime.Now.AddDays(-5) }, }; pointOfAccess.ForEach(s => context.PointsOfAccess.Add(s)); context.SaveChanges(); var registrations = new List <Registration> { new Registration { PointOfAccessID = 1, DeviceID = 1, DateCreated = DateTime.Now, }, new Registration { PointOfAccessID = 1, DeviceID = 2, DateCreated = DateTime.Now, }, new Registration { PointOfAccessID = 2, DeviceID = 1, DateCreated = DateTime.Now, }, }; registrations.ForEach(s => context.Registrations.Add(s)); context.SaveChanges(); var logs = new List <EntryLog> { new EntryLog { PointOfAccessID = 1, DeviceID = 2, DateCreated = DateTime.Now.AddDays(-1), Success = true }, new EntryLog { PointOfAccessID = 2, DeviceID = 1, DateCreated = DateTime.Now.AddDays(-2), Success = false }, }; logs.ForEach(s => context.EntryLogs.Add(s)); context.SaveChanges(); }