示例#1
0
        public object GetGroup([FromQuery] GroupIdentityModel groupIdentity)
        {
            var group        = groupRepository.Select(groupIdentity.GroupId);
            var membersCount = groupRepository.SelectMembersCount(groupIdentity.GroupId);

            return(GroupModel.Create(group, membersCount));
        }
示例#2
0
        public object CreateGroup([FromQuery] NewGroupInfoQueryModel groupInfo, [FromQuery] TokenQueryModel tokenData)
        {
            if (groupInfo.Name.Length > MaxGroupNameLength)
            {
                throw new Exceptions.FormatException("Group name is too long.", "group name is too long");
            }

            if (!Enum.IsDefined(typeof(GroupType), groupInfo.Type))
            {
                throw new Exceptions.FormatException("Unknown group type.", "unknown group type");
            }

            var token = tokenRepository.ValidateToken(tokenData.Token);
            var group = groupRepository.CreateGroup(groupInfo.Name, groupInfo.Type, token.UserUuid);

            return(GroupModel.Create(group));
        }
示例#3
0
 public ActionResult Create(FormCollection collection)
 {
     if (!AccessActions.IsAccess("Groups::Write"))
     {
         System.Web.Routing.RouteValueDictionary route = new System.Web.Routing.RouteValueDictionary();
         route.Add("err", "Нет доступа!");
         return(RedirectToAction("Error", "User", route));
     }
     try
     {
         GroupModel theGroup = new GroupModel();
         theGroup.Name     = collection["Name"];
         theGroup.BranchID = Convert.ToInt32(collection["BranchID"]);
         theGroup.Create();
         return(RedirectToAction("Index"));
     }
     catch
     {
         //return View("Index");
         return(RedirectToAction("Index"));
     }
 }