示例#1
0
 public static User User(int id = 0, string name = "Miku", UserGroupId group = UserGroupId.Regular, string email = "")
 {
     return(new User(name, "123", email, 0)
     {
         GroupId = group, Id = id
     });
 }
示例#2
0
        public PartialFindResult <UserForApiContract> GetList(
            string query                = "",
            UserGroupId groups          = UserGroupId.Nothing,
            DateTime?joinDateAfter      = null,
            DateTime?joinDateBefore     = null,
            NameMatchMode nameMatchMode = NameMatchMode.Auto,
            int start                 = 0,
            int maxResults            = 10,
            bool getTotalCount        = false,
            UserSortRule?sort         = null,
            bool includeDisabled      = false,
            bool onlyVerified         = false,
            string knowsLanguage      = null,
            UserOptionalFields fields = UserOptionalFields.None)
        {
            var queryParams = new UserQueryParams {
                Common              = new CommonSearchParams(SearchTextQuery.Create(query, nameMatchMode), false, false),
                Group               = groups,
                IncludeDisabled     = includeDisabled,
                OnlyVerifiedArtists = onlyVerified,
                KnowsLanguage       = knowsLanguage,
                JoinDateAfter       = joinDateAfter,
                JoinDateBefore      = joinDateBefore,
                Sort   = sort ?? UserSortRule.Name,
                Paging = new PagingProperties(start, maxResults, getTotalCount)
            };

            return(queries.GetUsers(queryParams, user => new UserForApiContract(user, userIconFactory, fields)));
        }
示例#3
0
 public Index(PagingData<UserContract> users, UserGroupId groupId, string name, bool verifiedArtists)
 {
     Users = users;
     GroupId = groupId;
     Name = name;
     VerifiedArtists = verifiedArtists;
 }
示例#4
0
 public static User User(int id = 0, string name = "Miku", UserGroupId group = UserGroupId.Regular, string email = "")
 {
     return(new User(name, "123", email, PasswordHashAlgorithms.Default)
     {
         GroupId = group, Id = id
     });
 }
示例#5
0
 public Index(PagingData <UserContract> users, UserGroupId groupId, string name, bool verifiedArtists)
 {
     Users           = users;
     GroupId         = groupId;
     Name            = name;
     VerifiedArtists = verifiedArtists;
 }
 public UserAddedToGroup(UserGroupId userGroupId, UserAccountId userAccountId, string userGroupName, string userName)
 {
     UserGroupId   = userGroupId;
     UserAccountId = userAccountId;
     UserGroupName = userGroupName;
     UserName      = userName;
 }
示例#7
0
 public VehicleAddedToUserGroup(UserGroupId userGroupId, VehicleId vehicleId, string licensePlateId, string?name)
 {
     UserGroupId    = userGroupId;
     VehicleId      = vehicleId;
     LicensePlateId = licensePlateId;
     Name           = name;
 }
示例#8
0
		/// <summary>
		/// Gets a group by Id.
		/// </summary>
		/// <param name="groupId">Group Id.</param>
		/// <returns>User group matching the Id, or <see cref="Nothing"/>, if no matching group is found.</returns>
		public static UserGroup GetGroup(UserGroupId groupId) {

			if (!groups.ContainsKey(groupId))
				return Nothing;

			return groups[groupId];

		}
示例#9
0
		public static PermissionCollection GetPermissions(UserGroupId groupId) {

			if (!groups.ContainsKey(groupId))
				return new PermissionCollection();

			return groups[groupId].Permissions;

		}
 public VehicleGroupChanged(
     VehicleId vehicleId,
     UserGroupId oldGroup,
     UserGroupId newGroup)
 {
     VehicleId = vehicleId;
     OldGroup  = oldGroup;
     NewGroup  = newGroup;
 }
示例#11
0
        public static PermissionCollection GetPermissions(UserGroupId groupId)
        {
            if (!groups.ContainsKey(groupId))
            {
                return(new PermissionCollection());
            }

            return(groups[groupId].Permissions);
        }
示例#12
0
        /// <summary>
        /// Gets a group by Id.
        /// </summary>
        /// <param name="groupId">Group Id.</param>
        /// <returns>User group matching the Id, or <see cref="Nothing"/>, if no matching group is found.</returns>
        public static UserGroup GetGroup(UserGroupId groupId)
        {
            if (!groups.ContainsKey(groupId))
            {
                return(Nothing);
            }

            return(groups[groupId]);
        }
示例#13
0
 public Driver(DriverId id, string firstName, string lastName, string description,
               UserGroupId userGroupId, DriverGroup group)
 {
     Id          = id;
     FirstName   = firstName;
     LastName    = lastName;
     Description = description;
     UserGroupId = userGroupId;
     Group       = group;
 }
 public VehicleGroupAddedToUserGroup(
     TenantId tenantId,
     VehicleGroupId vehicleGroupId,
     string vehicleGroupName,
     UserGroupId userGroupId,
     string userGroupName)
 {
     TenantId         = tenantId;
     VehicleGroupId   = vehicleGroupId;
     VehicleGroupName = vehicleGroupName;
     UserGroupId      = userGroupId;
     UserGroupName    = userGroupName;
 }
示例#15
0
        private PartialFindResult <UserContract> CallGetUsers(UserGroupId groupId = UserGroupId.Nothing, string name = null, bool disabled = false, bool verifiedArtists = false, UserSortRule sortRule = UserSortRule.Name, PagingProperties paging = null)
        {
            var queryParams = new UserQueryParams {
                Common              = new CommonSearchParams(SearchTextQuery.Create(name), false, false),
                Group               = groupId,
                IncludeDisabled     = disabled,
                OnlyVerifiedArtists = verifiedArtists,
                Sort   = sortRule,
                Paging = paging ?? new PagingProperties(0, 10, true)
            };

            return(data.GetUsers(queryParams, u => new UserContract(u)));
        }
示例#16
0
 public AddVehicle(
     string licensePlateId, UserGroupId userGroupId,
     string?brand, string?model, string name, int?mileage,
     VehicleTypeId?vehicleTypeId, VehicleGroupId?vehicleGroupId)
 {
     LicensePlateId = licensePlateId;
     UserGroupId    = userGroupId;
     Brand          = brand;
     Model          = model;
     Name           = name;
     Mileage        = mileage;
     VehicleTypeId  = vehicleTypeId;
     VehicleGroupId = vehicleGroupId;
 }
示例#17
0
 public PartialFindResult <UserForApiContract> GetList(
     string query                = "",
     UserGroupId groups          = UserGroupId.Nothing,
     NameMatchMode nameMatchMode = NameMatchMode.Auto,
     int start                 = 0,
     int maxResults            = 10,
     bool getTotalCount        = false,
     UserSortRule?sort         = null,
     bool includeDisabled      = false,
     bool onlyVerified         = false,
     string knowsLanguage      = null,
     UserOptionalFields fields = UserOptionalFields.None)
 {
     return(queries.GetUsers(SearchTextQuery.Create(query, nameMatchMode), groups, includeDisabled, onlyVerified, knowsLanguage, sort ?? UserSortRule.Name,
                             new PagingProperties(start, maxResults, getTotalCount), user => new UserForApiContract(user, userIconFactory, fields)));
 }
示例#18
0
        public ActionResult UsersPaged(UserGroupId groupId = UserGroupId.Nothing, string name = "", UserSortRule sortRule = UserSortRule.RegisterDate, int totalCount = 0, int page = 1)
        {
            var pageIndex = page - 1;
            var result    = Service.GetUsers(groupId, name, sortRule, PagingProperties.CreateFromPage(pageIndex, usersPerPage, false));
            var data      = new PagingData <UserContract>(result.Items.ToPagedList(pageIndex, usersPerPage, totalCount), null, "Index", "usersList");

            data.RouteValues = new RouteValueDictionary(new { groupId, sortRule, totalCount, action = "Index" });

            if (Request.IsAjaxRequest())
            {
                return(PartialView("PagedUsers", data));
            }
            else
            {
                return(View("PagedUsers", data));
            }
        }
示例#19
0
        public PartialFindResult <UserContract> GetUsers(UserGroupId groupId, string name, UserSortRule sortRule, PagingProperties paging)
        {
            return(HandleQuery(session => {
                var users = AddOrder(session.Query <User>()
                                     .Where(u => (groupId == UserGroupId.Nothing || u.GroupId == groupId) && string.IsNullOrWhiteSpace(name) || u.Name.Contains(name)), sortRule)
                            .Skip(paging.Start)
                            .Take(paging.MaxEntries)
                            .ToArray()
                            .Select(u => new UserContract(u))
                            .ToArray();

                var count = paging.GetTotalCount ? session.Query <User>()
                            .Count(u => (groupId == UserGroupId.Nothing || u.GroupId == groupId) && string.IsNullOrWhiteSpace(name) || u.Name.Contains(name)) : 0;

                return new PartialFindResult <UserContract>(users, count);
            }));
        }
示例#20
0
        public PartialFindResult <UserContract> GetUsers(UserGroupId groupId, string name, bool disabled, bool verifiedArtists, UserSortRule sortRule, PagingProperties paging)
        {
            return(repository.HandleQuery(ctx => {
                var usersQuery = ctx.Query();

                if (groupId != UserGroupId.Nothing)
                {
                    usersQuery = usersQuery.Where(u => u.GroupId == groupId);
                }

                if (!string.IsNullOrWhiteSpace(name))
                {
                    usersQuery = usersQuery.Where(u => u.Name.Contains(name));
                }

                if (!disabled)
                {
                    usersQuery = usersQuery.Where(u => u.Active);
                }

                if (verifiedArtists)
                {
                    usersQuery = usersQuery.Where(u => u.AllOwnedArtists.Any());
                }

                var users = AddOrder(usersQuery, sortRule)
                            .Skip(paging.Start)
                            .Take(paging.MaxEntries)
                            .ToArray()
                            .Select(u => new UserContract(u))
                            .ToArray();

                var count = paging.GetTotalCount ? usersQuery.Count() : 0;

                return new PartialFindResult <UserContract>(users, count);
            }));
        }
示例#21
0
 public UserRemovedFromGroup(UserGroupId userGroupId, UserAccountId userAccountId)
 {
     UserGroupId   = userGroupId;
     UserAccountId = userAccountId;
 }
示例#22
0
 public Index(PagingData<UserContract> users, UserGroupId groupId, string name)
 {
     Users = users;
     GroupId = groupId;
     Name = name;
 }
示例#23
0
 public Index(PagingData <UserContract> users, UserGroupId groupId, string name)
 {
     Users   = users;
     GroupId = groupId;
     Name    = name;
 }
示例#24
0
		public static User User(int id = 0, string name = "Miku", UserGroupId group = UserGroupId.Regular, string email = "") {
			return new User(name, "123", email, 0) { GroupId = group, Id = id };
		}
示例#25
0
 public VehicleGroupRemovedFromUserGroup(
     VehicleGroupId vehicleGroupId, UserGroupId userGroupId)
 {
     VehicleGroupId = vehicleGroupId;
     UserGroupId    = userGroupId;
 }
示例#26
0
 private PartialFindResult <UserContract> CallGetUsers(UserGroupId groupId = UserGroupId.Nothing, string name = null, bool disabled = false, bool verifiedArtists = false, UserSortRule sortRule = UserSortRule.Name, PagingProperties paging = null)
 {
     return(data.GetUsers(SearchTextQuery.Create(name), groupId, disabled, verifiedArtists, sortRule, paging ?? new PagingProperties(0, 10, true), u => new UserContract(u)));
 }
        private void TestCanEdit(bool expected, EntryStatus entryStatus = EntryStatus.Finished, UserGroupId userGroup = UserGroupId.Regular)
        {
            _artist.Status = entryStatus;
            _user.GroupId  = userGroup;

            var result = EntryPermissionManager.CanEdit(new FakePermissionContext(_user), _artist);

            result.Should().Be(expected, "result");
        }
示例#28
0
		private PartialFindResult<UserContract> CallGetUsers(UserGroupId groupId = UserGroupId.Nothing, string name = null, bool disabled = false, bool verifiedArtists = false, UserSortRule sortRule = UserSortRule.Name, PagingProperties paging = null) {
			return data.GetUsers(groupId, name, disabled, verifiedArtists, sortRule, paging ?? new PagingProperties(0, 10, true));
		}
示例#29
0
 public UserGroup(UserGroupId id, PermissionCollection permissions)
 {
     this.Id          = id;
     this.Permissions = permissions;
 }
        public static bool CanEditGroupTo(IUserPermissionContext permissionContext, UserGroupId groupId)
        {
            ParamIs.NotNull(() => permissionContext);

            return(permissionContext.UserGroupId == UserGroupId.Admin || permissionContext.UserGroupId > groupId);
        }
示例#31
0
		public UserGroup(UserGroupId id, params PermissionToken[] permissions) {
			this.Id = id;
			this.Permissions = new PermissionCollection(permissions);
		}
示例#32
0
        public ActionResult UsersPaged(UserGroupId groupId = UserGroupId.Nothing, string name = "", UserSortRule sortRule = UserSortRule.RegisterDate, int totalCount = 0, int page = 1)
        {
            var pageIndex = page - 1;
            var result = Service.GetUsers(groupId, name, sortRule, PagingProperties.CreateFromPage(pageIndex, usersPerPage, false));
            var data = new PagingData<UserContract>(result.Items.ToPagedList(pageIndex, usersPerPage, totalCount), null, "Index", "usersList");
            data.RouteValues = new RouteValueDictionary(new { groupId, sortRule, totalCount, action = "Index" });

            if (Request.IsAjaxRequest())
                return PartialView("PagedUsers", data);
            else
                return View("PagedUsers", data);
        }
 public GetVehicleInUserGroup(UserGroupId userGroupId)
 {
     UserGroupId = userGroupId;
 }
 public VehicleInVehicleGroupQuery(UserGroupId userGroupId)
 {
     UserGroupId = userGroupId;
 }
        private void TestCanDelete(bool expected, EntryStatus entryStatus = EntryStatus.Finished, UserGroupId userGroup = UserGroupId.Regular)
        {
            _artist.Status = entryStatus;
            _user.GroupId  = userGroup;

            var result = CanDelete(_user, _artist);

            result.Should().Be(expected, "result");
        }
示例#36
0
		public UserGroup(UserGroupId id, PermissionCollection permissions) {
			this.Id = id;
			this.Permissions = permissions;
		}
示例#37
0
 public UserGroup(UserGroupId id, UserGroup parent, params PermissionToken[] permissions)
 {
     this.Id          = id;
     this.Permissions = parent.Permissions + new PermissionCollection(permissions);
 }
        public static bool CanEditUser(IUserPermissionContext permissionContext, UserGroupId groupId)
        {
            ParamIs.NotNull(() => permissionContext);

            return(CanEditGroupTo(permissionContext, groupId));
        }
        private void TestCanEdit(bool expected, EntryStatus entryStatus = EntryStatus.Finished, UserGroupId userGroup = UserGroupId.Regular)
        {
            artist.Status = entryStatus;
            user.GroupId  = userGroup;

            var result = EntryPermissionManager.CanEdit(new FakePermissionContext(user), artist);

            Assert.AreEqual(expected, result, "result");
        }