コード例 #1
0
ファイル: CommandGetAll.cs プロジェクト: tecssil/RestExercise
        /// <summary>
        /// Execution of the Command
        /// </summary>
        /// <param name="param">Boolean</param>
        /// <returns>List of Users</returns>
        public override List <Entity> Execute(bool param)
        {
            string        strClass = "CommandGetAll";
            List <Entity> list     = new List <Entity>();

            try
            {
                IDaoUser daoUser = FactoryDao.GetDaoUser();
                DataSet  dsUser  = daoUser.GetAll();

                Command <DataSet, List <Entity> > commandConvertToJSON = FactoryCommand.GetCommandConvertUserIntoJSON();

                list = commandConvertToJSON.Execute(dsUser);
            }
            catch (Exception e)
            {
                IDaoUser daoUser = FactoryDao.GetDaoUser();
                daoUser.CreateLog(strClass, "There was a problem exectuting the command to get all users", true);
                throw new Exception("There was a problem exectuting the command to get all users", e);
            }
            return(list);
        }
コード例 #2
0
        /// <summary>
        /// Execution of the Command
        /// </summary>
        /// <param name="param">Id</param>
        /// <returns>User</returns>
        public override Entity Execute(string param)
        {
            string strClass = "CommandGetUser";
            Entity user     = FactoryEntity.GetUser();

            try
            {
                IDaoUser daoUser = FactoryDao.GetDaoUser();
                DataSet  dsUser  = daoUser.GetById(param);

                Command <DataSet, List <Entity> > commandConvertToJSON = FactoryCommand.GetCommandConvertUserIntoJSON();

                user = commandConvertToJSON.Execute(dsUser)[0];
            }
            catch (Exception e)
            {
                IDaoUser daoUser = FactoryDao.GetDaoUser();
                daoUser.CreateLog(strClass, "There was a problem exectuting the command to get one user", true);
                throw new Exception("There was a problem exectuting the command to get one user", e);
            }
            return(user);
        }