Пример #1
0
        public OperationResult <IList <IProductDTO> > GetAllProducts()
        {
            OperationResult <IList <IProductDTO> > operationResult = null;

            try
            {
                var productDAC = (IProductDAC)DACFactory.Instance.Create(DACType.Product);
                var products   = productDAC.ReadAllProducts();

                operationResult = products != null
                                                      ? OperationResult <IList <IProductDTO> > .CreateSuccessResult(products)
                                                      : OperationResult <IList <IProductDTO> > .CreateFailureResult(
                    ResourceUtility.GetCaptionFor(
                        ResourceConstants.Training.TrainingPlan.Index.Messages
                        .FailedToFetchTrainingCompanies));
            }
            catch (DACException dacEx)
            {
                operationResult = OperationResult <IList <IProductDTO> > .CreateErrorResult(dacEx.Message, dacEx.StackTrace);
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex);
                operationResult = OperationResult <IList <IProductDTO> > .CreateErrorResult(ex.Message, ex.StackTrace);
            }
            return(operationResult);
            //return PersistSvr<Order>.GetAll().ToList();
        }
Пример #2
0
        /// <summary>
        /// Creates Survey
        /// </summary>
        /// <param name="surveyDto"></param>
        /// <returns></returns>
        public OperationResult <ISurveyDTO> CreateSurvey(ISurveyDTO surveyDto)
        {
            OperationResult <ISurveyDTO> operationResult = null;

            try
            {
                var surveyDac = (ISurveyDAC)DACFactory.Instance.Create(DACType.Survey);

                var resultDto = surveyDac.CreateSurvey(surveyDto);
                operationResult = resultDto != null
                                                      ? OperationResult <ISurveyDTO> .CreateSuccessResult(surveyDto)
                                                      : OperationResult <ISurveyDTO> .CreateFailureResult(
                    ResourceUtility.GetCaptionFor(
                        ResourceConstants.Survey.ErrorMessages.FailedToCreateSurvey));
            }
            catch (DACException dacEx)
            {
                operationResult = OperationResult <ISurveyDTO> .CreateErrorResult(dacEx.Message, dacEx.StackTrace);
            }
            catch (Exception ex)
            {
                ExceptionManager.HandleException(ex);
                operationResult = OperationResult <ISurveyDTO> .CreateErrorResult(ex.Message, ex.StackTrace);
            }
            return(operationResult);
        }
Пример #3
0
 /// <summary>
 /// This Method is used to get the list of surveys and put in cache
 /// </summary>
 public static IList <ISurveyDTO> FetchAllSurveys()
 {
     if (CacheManager <SurveyState> .Data.Surveys == null)
     {
         OperationResult <IList <ISurveyDTO> > surveys = null;
         ISurveyBDC surveyBDC = (ISurveyBDC)BDCFactory.Instance.Create(BDCType.Survey);
         surveys = surveyBDC.GetAllSurveys();
         if (surveys != null && surveys.IsValid())
         {
             CacheManager <SurveyState> .Data.Surveys = surveys.Data;
         }
         else
         {
             throw new Exception(ResourceUtility.GetCaptionFor(ResourceConstants.Survey.ErrorMessages.FailedToFetchSurvey));
         }
     }
     return(CacheManager <SurveyState> .Data.Surveys);
 }