public ActionResult DeleteConfirmed(int id)
        {
            BlockedSite blockedSite = db.BlockedSites.Find(id);

            db.BlockedSites.Remove(blockedSite);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        public ActionResult DeleteSiteConfirmed(int siteId)
        {
            BlockedSite blockedSite = _db.BlockedSites.Find(siteId);
            var         computerId  = blockedSite?.ComputerUser.ComputerId;

            _db.BlockedSites.Remove(blockedSite);
            _db.SaveChanges();
            return(RedirectToAction("Users", "Users", new { computerId = computerId }));
        }
Exemplo n.º 3
0
 public static BlockedSiteResource ToResource(this BlockedSite blockedSite)
 {
     return(new BlockedSiteResource()
     {
         Name = blockedSite.Name,
         ComputerUserId = blockedSite.ComputerUserId,
         Active = blockedSite.Active,
         BlockedSiteId = blockedSite.BlockedSiteId,
         UrlAddress = blockedSite.UrlAddress
     });
 }
 public ActionResult Edit([Bind(Include = "BlockedSiteId,ComputerUserId,Name,UrlAddress,Active")] BlockedSite blockedSite)
 {
     if (ModelState.IsValid)
     {
         db.Entry(blockedSite).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ComputerUserId = new SelectList(db.ComputerUsers, "ComputerUserId", "Name", blockedSite.ComputerUserId);
     return(View(blockedSite));
 }
Exemplo n.º 5
0
        public ActionResult EditSite([Bind(Include = "BlockedSiteId,ComputerUserId,Name,UrlAddress,Active")] BlockedSite blockedSite)
        {
            if (ModelState.IsValid)
            {
                _db.Entry(blockedSite).State = EntityState.Modified;
                _db.SaveChanges();

                return(RedirectToAction("Users", "Users", new { computerId = _db.ComputerUsers.FirstOrDefault(u => u.ComputerUserId == blockedSite.ComputerUserId)?.ComputerId }));
            }
            ViewBag.ComputerUserId = new SelectList(_db.ComputerUsers.Where(u => u.ComputerId == blockedSite.ComputerUser.ComputerId), "ComputerUserId", "Name", blockedSite.ComputerUserId);
            return(View(blockedSite));
        }
        // GET: TempBlockedSites/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BlockedSite blockedSite = db.BlockedSites.Find(id);

            if (blockedSite == null)
            {
                return(HttpNotFound());
            }
            return(View(blockedSite));
        }
        // GET: TempBlockedSites/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BlockedSite blockedSite = db.BlockedSites.Find(id);

            if (blockedSite == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ComputerUserId = new SelectList(db.ComputerUsers, "ComputerUserId", "Name", blockedSite.ComputerUserId);
            return(View(blockedSite));
        }
Exemplo n.º 8
0
        public ActionResult SiteDetails(int?siteId)
        {
            if (siteId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BlockedSite blockedSite = _db.BlockedSites.Find(siteId);

            if (blockedSite == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ComputerId = blockedSite.ComputerUser.ComputerId;
            return(View(blockedSite));
        }
Exemplo n.º 9
0
        public ActionResult EditSite(int?siteId)
        {
            if (siteId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BlockedSite blockedSite = _db.BlockedSites.Find(siteId);

            if (blockedSite == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ComputerId     = blockedSite.ComputerUser.ComputerId;
            ViewBag.ComputerUserId = new SelectList(_db.ComputerUsers.Where(u => u.ComputerId == blockedSite.ComputerUser.ComputerId), "ComputerUserId", "Name", blockedSite.ComputerUserId);
            return(View(blockedSite));
        }
Exemplo n.º 10
0
        public ActionResult AddSite([Bind(Include = "BlockedSiteId,ComputerUserId,Name,UrlAddress,Active")] BlockedSite blockedSite)
        {
            if (ModelState.IsValid)
            {
                _db.BlockedSites.Add(blockedSite);
                _db.SaveChanges();
                var site = _db.BlockedSites.FirstOrDefault(s => s.BlockedSiteId == blockedSite.BlockedSiteId);
                if (site?.ComputerUser != null)
                {
                    ViewBag.ComputerId = site.ComputerUser.ComputerId;
                }
                return(RedirectToAction("Users"));
            }

            ViewBag.ComputerUserId = new SelectList(_db.ComputerUsers, "ComputerUserId", "Name", blockedSite.ComputerUserId);
            return(View(blockedSite));
        }
Exemplo n.º 11
0
        private static void GenerateBlockedSites(int computerUserId)
        {
            var sitesAmount = Settings.MaxAmountOfBlockedSites.Random();

            for (var i = 0; i < sitesAmount; i++)
            {
                var url  = Samples.BlockedSites.Random();
                var site = new BlockedSite
                {
                    ComputerUserId = computerUserId,
                    Name           = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(url.ToLower()),
                    UrlAddress     = url
                };
                Db.BlockedSites.Add(site);
                Db.SaveChanges();
                LocalLogger.Log($"                      Site {site.UrlAddress} has been blocked");
                //LocalLogger.Log();
                _blockedSitesCounter++;
            }
        }