Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="expression"></param>
        /// <returns></returns>
        public IQueryable <CustomerInfo> Read(Expression <Func <CustomerInfo, bool> > expression)
        {
            var reader      = new EntityReader <CustomerInfo>();
            var returnValue = reader.GetByWhere(expression);

            return(returnValue);
        }
Example #2
0
 public IEnumerable <IPerson> Post([FromBody] PersonDto data)
 {
     using (var entityReader = new EntityReader <PersonInfo>())
     {
         var searchResults = entityReader.GetByWhere(x => x.FirstName.Contains(data.FirstName) || x.LastName.Contains(data.LastName) || x.BirthDate == data.BirthDate || x.Key == data.Key || x.Id == data.Id).Take(MaxRecords);
         return(searchResults);
     }
 }
Example #3
0
        public void Model_CustomerSearch_GetBySearchFields()
        {
            var searchChar  = "i";
            var searchModel = new CustomerSearchModel()
            {
                FirstName = searchChar, LastName = searchChar
            };
            var reader  = new EntityReader <CustomerInfo>();
            var results = reader.GetByWhere(x => x.Key == searchModel.Key || x.FirstName.Contains(searchModel.FirstName) || x.LastName.Contains(searchModel.LastName) || x.BirthDate == searchModel.BirthDate);

            Assert.IsTrue(results.Count() > 0);
            searchModel.Results.FillRange(results);
            Assert.IsTrue(searchModel.FirstName == searchChar && searchModel.LastName == searchChar);
            Assert.IsTrue(searchModel.Results.Count() > 0);
        }
Example #4
0
        public IActionResult Post([FromBody] CustomerModel data)
        {
            var model         = new CustomerSearchModel();
            var reader        = new EntityReader <CustomerInfo>();
            var searchResults = reader.GetByWhere(x => x.Key == data.Key || x.FirstName.Contains(data.FirstName) || x.LastName.Contains(data.LastName) || x.BirthDate == data.BirthDate);
            var form          = Request.ReadFormAsync();

            model.Fill(data);
            if (searchResults.Any())
            {
                model.Results.FillRange(searchResults);
            }

            return(Ok(model));
        }
Example #5
0
        public IActionResult Get(string key = "-1", string firstName = "", string lastName = "")
        {
            var model = new CustomerSearchModel()
            {
                Id = key.TryParseInt32(), Key = key.TryParseGuid(), FirstName = firstName, LastName = lastName
            };
            var reader        = new EntityReader <CustomerInfo>();
            var searchResults = reader.GetByWhere(x => x.Key == model.Key || x.FirstName.Contains(model.FirstName) || x.LastName.Contains(model.LastName) || x.BirthDate == model.BirthDate);


            if (searchResults.Any())
            {
                model.Results.FillRange(searchResults);
            }

            return(Ok(model));
        }
Example #6
0
        public IEnumerable <IPerson> Get(string idOrKey, string firstName, string lastName)
        {
            var returnValue = new List <PersonInfo>();
            var id          = idOrKey.TryParseInt32();
            var key         = idOrKey.TryParseGuid();

            using (var entityReader = new EntityReader <PersonInfo>())
            {
                var searchResults = entityReader.GetByWhere(x => x.FirstName.Contains(firstName) || x.LastName.Contains(lastName) || x.Key == key || x.Id == id).Take(MaxRecords);

                if (searchResults.Any())
                {
                    returnValue.FillRange(searchResults);
                }
            }

            return(returnValue);
        }