コード例 #1
0
        public void SetStatusFromAuthorizations()
        {
            if (Authorizations.All(a => a.Status == AuthorizationStatus.Valid))
            {
                SetStatus(OrderStatus.Ready);
            }

            if (Authorizations.Any(a => a.Status.IsInvalid()))
            {
                SetStatus(OrderStatus.Invalid);
            }
        }
コード例 #2
0
        /// <summary>
        /// Assign authorizations directly
        /// </summary>
        /// <param name="authorizationsId">Authorizations Id</param>
        /// <returns>Task</returns>
        public void AssignAuthorizations(IEnumerable <int> authorizationsId)
        {
            if (Root)
            {
                throw new ForbiddenOperationDomainException("Root user");
            }

            foreach (var id in authorizationsId)
            {
                // Skip already added authorizations
                if (Authorizations.Any(i => i.DefAuthorizationId == id))
                {
                    continue;
                }

                Authorizations.Add(
                    new UserAuthorization
                {
                    DefAuthorizationId = id,
                    UserId             = Id
                });
            }
        }