Пример #1
0
        public ActionResult SaveAssociation(int id, string[] content)
        {
            try
            {
                new Guid(content[0]);
            }
            catch
            {
                content = new string[] { };
            }

            if (!IsUserLoggedIn())
            {
                TempData["RedirectMessage"] = "Access denied. Please login.";
                return(RedirectToAction("Index", "Home"));
            }

            bool success = false;

            using (ContentBeaconDBContext db = new ContentBeaconDBContext())
            {
                success = db.SaveContentBeacons(id, content);
            }

            return(RedirectToAction("Index", "Contents", new { success = success }));
        }
Пример #2
0
        public ActionResult Associate(int id)
        {
            ContentBeacon cb = new ContentBeacon();

            List <string> availableBeacons = new List <string>();

            using (BeaconDBContext db = new BeaconDBContext())
            {
                availableBeacons = db.GetAllBeaconsIds();
            }

            if (id < 0)
            {
                return(RedirectToAction("Error", "Home", new { id = 0 }));
            }

            if (id > 0)
            {
                using (ContentDBContext db = new ContentDBContext())
                {
                    if (db.GetContentById(id).id == 0)
                    {
                        return(RedirectToAction("Error", "Home", new { id = 0 }));
                    }
                }

                using (ContentBeaconDBContext db = new ContentBeaconDBContext())
                {
                    cb = db.GetContentBeaconsById(id);

                    availableBeacons = availableBeacons.Except(cb.BeaconIds).ToList();
                }
            }

            ViewData["availableBeacons"] = availableBeacons;

            return(View(cb));
        }