Exemple #1
0
        protected override void OnRequest()
        {
            base.OnRequest();

            string marketLocation = getParameter("location");

            try
            {
                MarketListModel marketList = null;
                using (Controller.Market controllerMarket = new Controller.Market())
                {
                    marketList = controllerMarket.GetMarketList(marketLocation, null);
                }

                WriteJson(marketList);
            }
            catch (UnfulfilException ex)
            {
                WriteUnfulfil(ex.DisplayMessage);
            }
            catch (Database.Exception ex)
            {
                WriteException(ex);
            }
            catch (Exception ex)
            {
                WriteException(ex);
            }
        }
Exemple #2
0
        public MarketListModel GetMarketList(String marketLocation, String marketType)
        {
            string where = "";
            if (!String.IsNullOrWhiteSpace(marketLocation))
            {
                where += String.Format("view_marketlist.market_location = '{0}'", marketLocation);
            }


            string where_marketType = "";

            if (!String.IsNullOrWhiteSpace(marketType))
            {
                if (where.Length > 0)
                {
                    where += " AND ";
                }

                where += String.Format("view_marketlist.market_typename = '{0}'", marketType);
            }

            List <ViewMarketListModel> list = db.SelectData <ViewMarketListModel>("view_marketlist", null, where, false, "view_marketlist.market_name DESC");

            if (list == null)
            {
                throw new UnfulfilException("/language/database/no_record");
            }

            MarketListModel marketList = new MarketListModel();

            foreach (ViewMarketListModel market in list)
            {
                marketList.Add(market);
            }
            return(marketList);
        }