Exemplo n.º 1
0
        /// <summary>
        /// Invokes the GetSessions business operation.
        /// </summary>
        private async Task <GetSessionsBusinessResponse> InvokeGetSessions(IDatabaseConnection databaseConnection)
        {
            try
            {
                // Build the GetSessions business request.
                GetSessionsBusinessRequest getSessionsBusinessRequest = new GetSessionsBusinessRequest();

                // Invoke the GetSessions business operation.
                GetSessionsBusinessResponse getSessionsBusinessResponse = await this.schedulingBusinessLogicComponent.GetSessions(databaseConnection, getSessionsBusinessRequest);

                // The business operation succeeded.
                return(getSessionsBusinessResponse);
            }
            catch (GetSessionsBusinessException getSessionsBusinessException)
            {
                // Wrap the GetSessions business exception into a service exception.
                ServiceException serviceException = ServiceExceptionBuilder.BuildServiceException(
                    "SchedulingServiceComponent.SessionsController.Get()",
                    getSessionsBusinessException,
                    getSessionsBusinessException.Errors.Select(error => error.ErrorCode.ToString()).ToArray(),
                    getSessionsBusinessException.Errors.Select(error => error.ErroneousValue).ToArray());

                // Throw the ErrorCode service exception.
                throw serviceException;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Invokes the NewSession business operation.
        /// </summary>
        private async Task <NewSessionBusinessResponse> InvokeNewSession(IDatabaseConnection databaseConnection, SessionResource resource)
        {
            try
            {
                // Build the NewSession business request.
                NewSessionBusinessRequest newSessionBusinessRequest = new NewSessionBusinessRequest();

                // Build the Session business request element.
                if (resource.Session != null)
                {
                    NewSessionBusinessRequest.SessionBusinessRequestElement sessionBusinessRequestElement = new NewSessionBusinessRequest.SessionBusinessRequestElement();
                    sessionBusinessRequestElement.Name      = resource.Session.Name;
                    sessionBusinessRequestElement.StartDate = resource.Session.StartDate;
                    newSessionBusinessRequest.Session       = sessionBusinessRequestElement;
                }

                // Invoke the NewSession business operation.
                NewSessionBusinessResponse newSessionBusinessResponse = await this.schedulingBusinessLogicComponent.NewSession(databaseConnection, newSessionBusinessRequest);

                // The business operation succeeded.
                return(newSessionBusinessResponse);
            }
            catch (NewSessionBusinessException newSessionBusinessException)
            {
                // Wrap the NewSession business exception into a service exception.
                ServiceException serviceException = ServiceExceptionBuilder.BuildServiceException(
                    "SchedulingServiceComponent.SessionsController.Post()",
                    newSessionBusinessException,
                    newSessionBusinessException.Errors.Select(error => error.ErrorCode.ToString()).ToArray(),
                    newSessionBusinessException.Errors.Select(error => error.ErroneousValue).ToArray());

                // Throw the service exception.
                throw serviceException;
            }
        }