Beispiel #1
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);
        }
        /// <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);
        }
Beispiel #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);
        }
Beispiel #4
0
        /// <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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #7
0
 public BllUser()
 {
     this.LiDaoUser = new DaoUser();
 }