Exemplo n.º 1
0
 public GenericOutput <Person> PersonSelect(PersonPredicate personPredicate)
 {
     return(Action("[Feed].[Person.Action]", new GenericInput <Person, PersonPredicate>
     {
         ActionType = ActionType.PersonSelect,
         Predicate = personPredicate
     }));
 }
Exemplo n.º 2
0
 private static PersonPredicate PersonPredicate(PersonPredicate personPredicate)
 {
     if (personPredicate == null)
     {
         personPredicate = new PersonPredicate();
     }
     personPredicate.IsPrivate = false;
     return(personPredicate);
 }
Exemplo n.º 3
0
        public IEnumerable<PersonDto> GetList(PersonPredicate predicate)
        {
            var connection = _session.GetPort<System.Data.Common.DbConnection>();

            DagentDatabase db = new DagentDatabase(connection);

            string sql = _sql;

            StringBuilder where = new StringBuilder();

            int suffix = 1;

            List<Parameter> parameters = new List<Parameter>();

            foreach (KeyValuePair<PersonPredicateItem, object> keyValue in predicate)
            {
                if (where.ToString() != string.Empty)
                {
                    where.Append(predicate.And ? " and " : " or ");
                    where.Append(Environment.NewLine);
                }

                string paramName = string.Empty;
                if (keyValue.Key == PersonPredicateItem.LikeName)
                {
                    paramName = string.Format("name_{0}", suffix);
                    where.Append(string.Format("Person.Name like @{0}", paramName));

                    parameters.Add(new Parameter(paramName, keyValue.Value.ToString() + "%"));
                }
                else if (keyValue.Key == PersonPredicateItem.City)
                {
                    paramName = string.Format("city_{0}", suffix);
                    where.Append(string.Format("Person.City = @{0}", paramName));

                    parameters.Add(new Parameter(paramName, keyValue.Value));
                }
            }

            if (where.ToString() != string.Empty)
            {
                sql = string.Format(sql, "where " + where.ToString());
            }

            IEnumerable<PersonDto> personDtos = db.Query<PersonDto>(sql, parameters.ToArray())
                .Unique("PersonId")
                .Each((dto, rows) => rows.Map(dto, x => x.HistoryList, "PersonId", "HistoryNo").Do())
                .EnumerateList();

            return personDtos;
        }
Exemplo n.º 4
0
        public GenericOutput <Person> PersonSelect(PersonPredicate personPredicate)
        {
            var genericOutput = ModelData.Instance.PersonSelect(personPredicate);
            var insidePersons = GetInsidePersons();

            foreach (var person in genericOutput.Entities)
            {
                if (person == null ||
                    !person.Id.HasValue ||
                    !insidePersons.ContainsKey(person.Id))
                {
                    continue;
                }
                person.IsInside = true;
            }
            return(genericOutput);
        }
Exemplo n.º 5
0
 public GenericOutput <Person> PersonSelect(PersonPredicate personPredicate)
 {
     return(ModelLogic.Instance.PersonSelect(personPredicate));
 }