public PeopleViewModel() : base(new PersonRepository())
        {
            ImportAttachmentFromDiskCommand =
                new RelayCommand(OnImportFromDisk, () => SelectedItem != null);
            ImportAttachmentFromClipboardCommand =
                new RelayCommand(OnImportFromClipboard, () => SelectedItem != null);
            SaveAttachmentToDiskCommand =
                new RelayCommand(OnSaveAttachmentToDisk,
                                 () => SelectedPersonAttachment != null);
            OpenAttachmentCommand =
                new RelayCommand(OnOpenAttachment,
                                 () => SelectedPersonAttachment != null);
            DeleteAttachmentCommand =
                new RelayCommand(OnDeleteAttachment,
                                 () => SelectedPersonAttachment != null);

            PersonCriteria = new PersonCriteria();
        }
        protected override void ApplyCriteriaAndOrder(PersonCriteria criteria, DbCommand command)
        {
            SqlCommand sqlCommand = (SqlCommand)command;

            sqlCommand.CommandText += " WHERE ACTIVE = 1";
            if (criteria.Role != null)
            {
                sqlCommand.CommandText += " AND r.type=@c_r_type";
                sqlCommand.Parameters.Add("@c_r_type", SqlDbType.VarChar).Value = criteria.Role.ToString();
            }

            if (criteria.WholeName != null)
            {
                sqlCommand.CommandText += " AND (Lower(p.FIRST_NAME) || Lower(p.LAST_NAME)) like '%' || LOWER(@c_whole_name) || '%'";
                sqlCommand.Parameters.Add("@c_whole_name", SqlDbType.VarChar).Value = criteria.WholeName;
            }
            sqlCommand.CommandText += " ORDER BY p.LOGIN";
        }
        public IList <Person> Select(PersonCriteria criteria, bool closeAtEnd = true)
        {
            db.Connect();

            DbCommand command = db.CreateCommand(GetSelectSql());

            ApplyCriteriaAndOrder(criteria, command);

            DbDataReader   reader  = db.Select(command);
            IList <Person> persons = Read(reader);

            reader.Close();

            if (closeAtEnd)
            {
                db.Close();
            }
            return(persons);
        }
Beispiel #4
0
        protected override void ApplyCriteriaAndOrder(PersonCriteria criteria, DbCommand command)
        {
            OracleCommand oracleCommand = (OracleCommand)command;

            oracleCommand.BindByName   = true;
            oracleCommand.CommandText += " WHERE ACTIVE = 1";
            if (criteria.Role != null)
            {
                oracleCommand.CommandText += " AND r.type=:c_r_type";
                oracleCommand.Parameters.Add("c_r_type", OracleDbType.Varchar2).Value = criteria.Role.ToString();
            }

            if (criteria.WholeName != null)
            {
                oracleCommand.CommandText += " AND (Lower(p.FIRST_NAME) || Lower(p.LAST_NAME)) like '%' || LOWER(:c_whole_name) || '%'";
                oracleCommand.Parameters.Add("c_whole_name", OracleDbType.Varchar2).Value = criteria.WholeName;
            }
            oracleCommand.CommandText += " ORDER BY p.LOGIN";
        }
Beispiel #5
0
        public IList <Person> GetAllUsers(PersonCriteria criteria)
        {
            IList <BreederStationDataLayer.Orm.Dto.Person> dtoPersons;

            if (criteria.Role == null)
            {
                dtoPersons = personGateway.Select(new BreederStationDataLayer.Orm.SelectCriteria.PersonCriteria {
                    Role = null, WholeName = criteria.WholeName
                });
            }
            else
            {
                dtoPersons = personGateway.Select(new BreederStationDataLayer.Orm.SelectCriteria.PersonCriteria {
                    Role = (BreederStationDataLayer.RoleEnum)(criteria.Role.Value), WholeName = criteria.WholeName
                });
            }
            IList <Person> persons = new List <Person>();

            foreach (BreederStationDataLayer.Orm.Dto.Person dtoPerson in dtoPersons)
            {
                persons.Add(mapDtoToDomainObject(dtoPerson));
            }
            return(persons);
        }
 protected abstract void ApplyCriteriaAndOrder(PersonCriteria criteria, DbCommand command);