Exemple #1
0
        public ActionResult CreateNewGroup([Bind(Include = "Name")] string groupName)
        {
            if (GroupNameExist(groupName)) {
                ModelState.AddModelError("errorCreateNewUser", "Username already exist");
                return View("../Group/Create");
            } else if (!CheckInput(groupName)) {
                ModelState.AddModelError("errorCreateNewUser", "invalid input");
                return View("../Group/Create");
            }
            Users user = (Users)Session["currentUser"];
            Groups group = new Groups();
            group.Owner = user.Username;
            group.Name = groupName;

            db.GroupsSet.Add(group);
            db.SaveChanges();

            return RedirectToAction("Index", "Group");
        }
Exemple #2
0
 public bool EvalGroupOwner(Groups group)
 {
     Users g = (Users)Session["currentUser"];
     return group.Owner == g.Username;
 }