Esempio n. 1
0
        /// <summary>
        /// method to get list of backends associated to user
        /// </summary>
        /// <param name="userID">takes userid as input</param>
        /// <returns>returns list of userbackends</returns>
        public List <UserBackendEntity> GetUserBackendsList(string userID, List <string> userbackends)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                //if userbackendid's not provided get all associated backends to user by default
                if (userbackends != null)
                {
                    SynchDAL synchdDAL = new SynchDAL();
                    //calling data access layer method
                    return(synchdDAL.GetUserAllBackends(userID, userbackends));
                }
                else
                {
                    UserBackendDAL userbackenddal = new UserBackendDAL();
                    return(userbackenddal.GetUserAllBackends(userID));
                }
            }
            catch (DataAccessException DALexception)
            {
                throw DALexception;
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                //LoggerHelper.WriteToLog(exception + " - Error in BL while getting userbackend list per user : "
                //+ exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error);
                throw new BusinessLogicException();
            }
        }
Esempio n. 2
0
        /// <summary>
        ///method to remove userbackends
        /// </summary>
        /// <param name="UserID">takes userid as input</param>
        public void RemoveBackends(string UserID)
        {
            string callerMethodName = string.Empty;

            try
            {
                //Get Caller Method name from CallerInformation class
                callerMethodName = CallerInformation.TrackCallerMethodName();
                UserBackendDAL userbackenddal = new UserBackendDAL();
                //to get all backends associated to user
                List <UserBackendEntity> alluserbackends = userbackenddal.GetUserAllBackends(UserID);
                if (alluserbackends != null && alluserbackends.Count > 0)
                {
                    //calling data access layer method to remove user backends
                    userbackenddal.RemoveBackends(alluserbackends);
                }
            }
            catch (DataAccessException DALexception)
            {
                throw DALexception;
            }
            catch (Exception exception)
            {
                InsightLogger.Exception(exception.Message, exception, callerMethodName);
                //LoggerHelper.WriteToLog(exception + " - Error in BL while removing userbackends : "
                //+exception.ToString(), CoreConstants.Priority.High, CoreConstants.Category.Error);
                throw new BusinessLogicException();
            }
        }
Esempio n. 3
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();
            }
        }