Esempio n. 1
0
        public ActionResult ConfirmToken(string username, string token)
        {
            if (WebSecurity.ConfirmAccount(username, token))
            {
                ViewBag.Authenticated = true;

                Entities db = new Entities();
                int UserId = db.webpages_Membership.Single(ent => ent.ConfirmationToken == token).UserId;
                UserProfile profile = db.UserProfiles.Single(ent => ent.UserId == UserId);

                Group newGroup = new Group()
                {
                    CreatedBy = profile.UserId,
                    Name = profile.UserName,
                    JoinLink = Guid.NewGuid().ToString()
                };

                profile.GroupsIn.Add(newGroup);
                db.SaveChanges();

                newGroup.FileDirectory = Server.MapPath("/Groups/" + newGroup.GroupId);
                System.IO.Directory.CreateDirectory(newGroup.FileDirectory);
                System.IO.Directory.CreateDirectory(newGroup.FileDirectory + "/Reports");
                System.IO.Directory.CreateDirectory(newGroup.FileDirectory + "/Plugins");
                System.IO.Directory.CreateDirectory(newGroup.FileDirectory + "/Scans");

                db.SaveChanges();
            }
            else
            {
                ViewBag.Authenticated = false;
            }
            return View();
        }
Esempio n. 2
0
        public ActionResult CreateGroup(Group model)
        {
            if (ModelState.IsValid)
            {
                Entities db = new Entities();
                UserProfile pro = db.UserProfiles.Single(u => u.UserId == WebSecurity.CurrentUserId);
                model.CreatedBy = pro.UserId;
                model.JoinLink = Guid.NewGuid().ToString();

                pro.GroupsIn.Add(model);
                db.SaveChanges();

                model.FileDirectory = Server.MapPath("/Groups/" + model.GroupId);

                System.IO.Directory.CreateDirectory(model.FileDirectory);
                System.IO.Directory.CreateDirectory(model.FileDirectory + "/Reports");
                System.IO.Directory.CreateDirectory(model.FileDirectory + "/Plugins");
                System.IO.Directory.CreateDirectory(model.FileDirectory + "/Scans");

                db.SaveChanges();

                return RedirectToAction("Manage");
            }
            else
                return View(model);
        }