public object GetGroup([FromQuery] GroupIdentityModel groupIdentity) { var group = groupRepository.Select(groupIdentity.GroupId); var membersCount = groupRepository.SelectMembersCount(groupIdentity.GroupId); return(GroupModel.Create(group, membersCount)); }
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)); }
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")); } }