コード例 #1
0
        /// <summary>
        /// Execution of the Command
        /// </summary>
        /// <param name="param">User</param>
        /// <returns>User</returns>
        public override Entity Execute(Entity param)
        {
            string strClass = "CommandUpdateUser";

            try
            {
                IDaoUser daoUser = FactoryDao.GetDaoUser();
                daoUser.Update((User)param);
            }
            catch (Exception e)
            {
                IDaoUser daoUser = FactoryDao.GetDaoUser();
                daoUser.CreateLog(strClass, "There was a problem exectuting the command to update users", true);
                throw new Exception("There was a problem exectuting the command to update users", e);
            }
            return(param);
        }
コード例 #2
0
        /// <summary>
        /// Execution of the Command
        /// </summary>
        /// <param name="param">Exception</param>
        /// <returns>bool</returns>
        public override bool Execute(Exception ex)
        {
            string strClass = "CommandCreateLog";

            try
            {
                IDaoUser daoUser = FactoryDao.GetDaoUser();
                daoUser.CreateLog(strClass, ex.Message, true);
            }
            catch (Exception e)
            {
                IDaoUser daoUser = FactoryDao.GetDaoUser();
                daoUser.CreateLog(strClass, "There was a problem creating the log entry", true);
                throw new Exception("There was a problem creating the log entry", e);
            }
            return(true);
        }
コード例 #3
0
        /// <summary>
        /// Execution of the Command
        /// </summary>
        /// <param name="param">Id</param>
        /// <returns>Boolean</returns>
        public override bool Execute(string param)
        {
            string strClass = "CommandRemoveUser";
            bool   result   = false;

            try
            {
                IDaoUser daoUser = FactoryDao.GetDaoUser();
                result = daoUser.Delete(param);
            }
            catch (Exception e)
            {
                IDaoUser daoUser = FactoryDao.GetDaoUser();
                daoUser.CreateLog(strClass, "There was a problem exectuting the command to delete users", true);
                throw new Exception("There was a problem exectuting the command to delete users", e);
            }
            return(result);
        }
コード例 #4
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);
        }
コード例 #5
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);
        }
コード例 #6
0
        /// <summary>
        /// Execution of the Command
        /// </summary>
        /// <param name="param">DataSet from DB</param>
        /// <returns>List of Users</returns>
        public override List <Entity> Execute(DataSet param)
        {
            string        strClass = "CommandConvertUserIntoJSON";
            List <Entity> list     = new List <Entity>();
            int           result;
            DateTime      resultDT;

            try
            {
                if (param != null)
                {
                    foreach (DataRow dr in param.Tables["DATA"].Rows)
                    {
                        Entity user = FactoryEntity.GetUser();

                        ((User)user).Id = (dr["USER_ID"] != null && !String.IsNullOrEmpty(dr["USER_ID"].ToString())) ?
                                          (int.TryParse(dr["USER_ID"].ToString(), out result) ? int.Parse(dr["USER_ID"].ToString()) : -1) : -1;
                        ((User)user).Name = (dr["USER_NAME"] != null && !String.IsNullOrEmpty(dr["USER_NAME"].ToString())) ?
                                            dr["USER_NAME"].ToString() : "";
                        ((User)user).Birthdate = (dr["USER_BIRTHDATE"] != null && !String.IsNullOrEmpty(dr["USER_BIRTHDATE"].ToString())) ?
                                                 (DateTime.TryParse(dr["USER_BIRTHDATE"].ToString(), out resultDT) ?
                                                  DateTime.Parse(dr["USER_BIRTHDATE"].ToString()).Month.ToString() + "-" +
                                                  DateTime.Parse(dr["USER_BIRTHDATE"].ToString()).Day.ToString() + "-" +
                                                  DateTime.Parse(dr["USER_BIRTHDATE"].ToString()).Year.ToString() : "") : "";

                        list.Add(user);
                    }
                }
            }
            catch (Exception e)
            {
                IDaoUser daoUser = FactoryDao.GetDaoUser();
                daoUser.CreateLog(strClass, "There was a problem converting the user into a JSON", true);
                throw new Exception("There was a problem converting the user into a JSON", e);
            }
            return(list);
        }