protected override void OnRequest() { base.OnRequest(); string productName = getParameter("product_name"); string marketName = getParameter("market_name"); try { MerchantListModel merchantList = null; using (Controller.Merchant controllerMerchant = new Controller.Merchant()) { if (MemberValid == true) { merchantList = controllerMerchant.GetMerchantList(productName, marketName); } else { merchantList = controllerMerchant.GetMerchantList(productName, marketName, 2); } } WriteSuccess <MerchantListModel>(merchantList); } catch (UnfulfilException ex) { WriteUnfulfil(ex.DisplayMessage); }catch (Exception ex) { WriteException(ex); } WriteEnd(); }
/// <summary> /// Returns our list of merchants /// </summary> /// <returns></returns> public async Task <ActionResult> MerchantList() { var model = new MerchantListModel(); model.Merchants = await new PushpayConnection().GetMerchants(""); return(Json(model, JsonRequestBehavior.AllowGet)); }
protected override void OnRequest() { base.OnRequest(); string merchantName = getParameter("merchant_name"); string merchantContact = getParameter("merchant_contact"); string merchantDescription = getParameter("merchant_description"); string productName = getParameter("product_name"); string marketName = getParameter("market_name"); try { MerchantListModel merchantList = null; using (Controller.Merchant controllerMerchant = new Controller.Merchant()) { merchantList = controllerMerchant.GetMerchantList(merchantName, merchantContact, merchantDescription, marketName, productName, null); } DatagridModel <ViewMerchantListModel> data = new DatagridModel <ViewMerchantListModel>(); data.total = (uint)merchantList.Count(); data.rows = merchantList; WriteJson(data); } catch (UnfulfilException ex) { WriteUnfulfil(ex.DisplayMessage); } catch (Exception ex) { WriteException(ex); } WriteEnd(); }
public MerchantListModel GetMerchantList(string merchantName, string merchantContact, string merchantDescription, string marketName, string productName, uint?merchantType) { string where = ""; if (!String.IsNullOrWhiteSpace(productName)) { where += string.Format("view_merchantlist.product_name = '{0}'", productName); } if (!String.IsNullOrWhiteSpace(marketName)) { if (!String.IsNullOrWhiteSpace(where)) { where += " AND "; } where += string.Format("view_merchantlist.market_name = '{0}'", marketName); } if (!String.IsNullOrWhiteSpace(merchantDescription)) { if (!String.IsNullOrWhiteSpace(where)) { where += " AND "; } where += string.Format("view_merchantlist.merchant_description like '%{0}%'", merchantDescription); } if (!String.IsNullOrWhiteSpace(merchantContact)) { if (!String.IsNullOrWhiteSpace(where)) { where += " AND "; } where += string.Format("view_merchantlist.merchant_contact like '%{0}%'", merchantContact); } if (!String.IsNullOrWhiteSpace(merchantName)) { if (!String.IsNullOrWhiteSpace(where)) { where += " AND "; } where += string.Format("view_merchantlist.merchant_name like '%{0}%'", merchantName); } if (merchantType != null) { if (!String.IsNullOrWhiteSpace(where)) { where += " AND "; } where += string.Format("view_merchantlist.merchant_type_id = '{0}'", merchantType); } //string.Format("view_merchantlist.product_name = '{0}' AND view_merchantlist.market_name = '{1}'", productName, marketName); List <ViewMerchantListModel> list = db.SelectData <ViewMerchantListModel>("view_merchantlist", null, where, true, "view_merchantlist.merchant_name DESC"); if (list == null) { throw new UnfulfilException("/language/database/no_record"); } MerchantListModel merchantList = new MerchantListModel(); foreach (ViewMerchantListModel merchant in list) { merchantList.Add(merchant); } return(merchantList); }