Esempio n. 1
0
        /// <summary>
        /// method to get all userbackends
        /// </summary>
        /// <param name="UserID">takes userid as input</param>
        /// <returns>returns list of user backend</returns>
        public IEnumerable <UserBackendDTO> GetUserAllBackends(string UserID)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                UserBackendDAL userbackenddal = new UserBackendDAL();
                //calling data access layer method to get user backends
                List <UserBackendEntity> alluserbackends = userbackenddal.GetUserAllBackends(UserID);
                //calling data access layer method to get user backend synch
                List <SynchEntity>    allbackendsynch     = userbackenddal.GetAllUserBackendsSynch(UserID);
                List <UserBackendDTO> userbackendsdtolist = new List <UserBackendDTO>();
                //check for null
                if (alluserbackends != null && alluserbackends.Count > 0)
                {
                    //converting userdevice entity to userdevice data transfer object
                    foreach (UserBackendEntity userbackendentity in alluserbackends)
                    {
                        UserBackendDTO userbackenddto = UserBackendEntityDTOMapper(userbackendentity);
                        SynchEntity    synchentity    = allbackendsynch.Where(m => m.RowKey.Equals(userbackendentity.BackendID)).FirstOrDefault();
                        //if user backend synch available then convert to dto
                        if (synchentity != null)
                        {
                            SynchDTO synchdto = DataProvider.ResponseObjectMapper <SynchDTO, SynchEntity>(synchentity);
                            userbackenddto.synch = synchdto;
                        }

                        userbackendsdtolist.Add(userbackenddto);
                    }
                }
                else
                {
                    userbackendsdtolist = null;
                }

                return((IEnumerable <UserBackendDTO>)userbackendsdtolist);
            }
            catch (DataAccessException DALexception)
            {
                throw DALexception;
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                //LoggerHelper.WriteToLog(exception + " - Error in BL while retreiving userbackends : "
                //+exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error);
                throw new BusinessLogicException();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// method to get single userbackend
        /// </summary>
        /// <param name="userID">takes userid as input</param>
        /// <param name="userBackendID">takes user backend id as input</param>
        /// <returns>returns user backend with id associated to user in the form of personalization response</returns>
        public PersonalizationResponseDTO <UserBackendDTO> GetUserBackend(string userID, string userBackendID)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                UserBackendDAL    userbackenddal    = new UserBackendDAL();
                UserBackendEntity userbackendentity = userbackenddal.GetUserBackend(userID, userBackendID);
                SynchEntity       synch             = userbackenddal.GetBackendSynch(userID, userBackendID);
                //converting userbackend entity to Response data transfer object
                var ResponseUserBackend = new PersonalizationResponseDTO <UserBackendDTO>();
                ///check for null
                if (userbackendentity != null)
                {
                    UserBackendDTO userbackenddto = UserBackendEntityDTOMapper(userbackendentity);
                    //adding synch to user backend
                    if (synch != null)
                    {
                        SynchDTO synchdto = DataProvider.ResponseObjectMapper <SynchDTO, SynchEntity>(synch);
                        userbackenddto.synch = synchdto;
                    }
                    ResponseUserBackend.result = userbackenddto;
                }
                else
                {
                    ResponseUserBackend.result = null;
                }
                return(ResponseUserBackend);
            }
            catch (DataAccessException DALexception)
            {
                throw DALexception;
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                //LoggerHelper.WriteToLog(exception + " - Error in BL while retreiving single userbackend : "
                //+exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error);
                throw new BusinessLogicException();
            }
        }