Beispiel #1
0
        public List <cust_mast> InquiryCustomerByText(CustomerAutoCompleteSearchView model)
        {
            using (var ctx = new ConXContext())
            {
                string sql = "select top 20 * from cust_mast";

                if (model.type == "name")
                {
                    sql += " where cust_name like @txt_name";
                    sql += " order by cust_name asc";
                }
                else
                {
                    sql += " where tel like @txt_tel";
                    sql += " order by tel asc";
                }

                List <cust_mast> customer = ctx.Database.SqlQuery <cust_mast>(sql,
                                                                              new SqlParameter("@txt_name", "%" + model.txt + "%"),
                                                                              new SqlParameter("@txt_tel", "%" + model.txt + "%")
                                                                              ).ToList();

                return(customer);
            }
        }
Beispiel #2
0
        public HttpResponseMessage postInquiryCustomerByText(CustomerAutoCompleteSearchView model)
        {
            try
            {
                var res = customerService.InquiryCustomerByText(model);

                return(Request.CreateResponse(HttpStatusCode.OK, res));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.ToString()));
            }
        }