public void SetStatusFromAuthorizations() { if (Authorizations.All(a => a.Status == AuthorizationStatus.Valid)) { SetStatus(OrderStatus.Ready); } if (Authorizations.Any(a => a.Status.IsInvalid())) { SetStatus(OrderStatus.Invalid); } }
/// <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 }); } }