public static PremiumSubscriptionModel GetModel(MobilePaywallDirect db, AndroidPremiumCustomer customer) { DirectContainer container = db.LoadContainer(string.Format(@" SELECT s.ServiceID, s.Name AS ServiceName, c.TwoLetterIsoCode, sce.Keyword, sce.Shortcode FROM MobilePaywall.core.TemplateServiceInfo AS i LEFT OUTER JOIN MobilePaywall.core.Service AS s ON i.ServiceID=s.ServiceID LEFT OUTER JOIN MobilePaywall.core.Country AS c ON s.FallbackCountryID=c.CountryID LEFT OUTER JOIN MobilePaywall.core.ServiceConfiguration AS sc ON s.ServiceConfigurationID=sc.ServiceConfigurationID LEFT OUTER JOIN MobilePaywall.core.ServiceConfigurationEntry AS sce ON sce.ServiceConfigurationID=sc.ServiceConfigurationID LEFT OUTER JOIN MobilePaywall.core.AndroidPremiumCustomerServiceMap AS apcsm ON apcsm.ServiceID=s.ServiceID WHERE i.IsPremiumSms=1 AND sce.Shortcode != '' AND sce.Keyword != '' AND i.Progress IN (5) AND (apcsm.AndroidPremiumCustomerID IS NULL OR apcsm.AndroidPremiumCustomerID!={0} OR (apcsm.AndroidPremiumCustomerID={0} AND apcsm.PaymentRequestID IS NULL)) AND c.CountryID={1}", customer.ID, customer.Country.ID)); if (!container.HasValue || container.ColumnCount == 0) { return(null); } return(new PremiumSubscriptionModel() { ServiceID = container.GetString("ServiceID"), ServiceName = container.GetString("ServiceName"), TwoLetterIsoCode = container.GetString("TwoLetterIsoCode"), Keyword = container.GetString("Keyword"), Shortcode = container.GetString("Shortcode") }); }
// GET: Entrance call from apk, first thing that will be called public ActionResult Call() { string uniqueID = Request["uniqueID"] != null ? Request["uniqueID"].ToString() : string.Empty; string msisdn = Request["msisdn"] != null ? Request["msisdn"].ToString() : string.Empty; string referrer = Request["referrer"] != null ? Request["referrer"].ToString() : string.Empty; string applicationName = Request["applicationName"] != null ? Request["applicationName"].ToString() : string.Empty; // Check values if (string.IsNullOrEmpty(uniqueID)) { Log.Error("Primium.Entrance:: No uniqueID"); return(this.Json(new { status = false }, JsonRequestBehavior.AllowGet)); } if (string.IsNullOrEmpty(applicationName)) { Log.Error("Primium.Entrance:: No application name"); return(this.Json(new { status = false }, JsonRequestBehavior.AllowGet)); } AndroidPremiumCustomer customer = this.GetCustomer(uniqueID, applicationName, Request.UserHostAddress, msisdn, referrer); // Find suitable service for subscription MobilePaywallDirect db = MobilePaywallDirect.Instance; PremiumSubscriptionModel subscriptionModel = PremiumSubscriptionModel.GetModel(db, customer); if (subscriptionModel == null) { Log.Debug("Primium.Entrance:: There is no suitable PSMS service for country=" + customer.Country.TwoLetterIsoCode); return(this.Json(new { status = false, customerID = customer.ID }, JsonRequestBehavior.AllowGet)); } string textmessage = string.Format("{0} /ac={1}", subscriptionModel.Keyword, customer.ID); AndroidPremiumCustomerServiceMap map = new AndroidPremiumCustomerServiceMap(-1, customer, null, Int32.Parse(subscriptionModel.ServiceID), subscriptionModel.Shortcode, textmessage, null, DateTime.Now, DateTime.Now); map.Insert(); int minuteWait = (new Random()).Next(2, 7); Log.Debug(string.Format("Primium.Entrance:: Customer:{0}, Service:{1}, Shortcode:{2}, Keyword:{3}, Wait: {4}", customer.ID, subscriptionModel.ServiceName, subscriptionModel.Shortcode, subscriptionModel.Keyword, minuteWait)); return(this.Json(new { status = true, minute = minuteWait, customerID = customer.ID, shortcode = subscriptionModel.Shortcode, textmessage = textmessage, }, JsonRequestBehavior.AllowGet)); }
// GET: Manager public ActionResult Index() { List <AndroidPremiumCustomer> android = AndroidPremiumCustomer.CreateManager().Load(); ManagerModel model = new ManagerModel(); model.Customers = android; return(View("Index", model)); }
public ActionResult FilterTable() { string _top = Request["top"] != null ? Request["top"].ToString() : string.Empty; string _from = Request["from"] != null ? Request["from"].ToString() : string.Empty; string _to = Request["to"] != null? Request["to"].ToString() : string.Empty; string _country = Request["country"] != null? Request["country"].ToString() : string.Empty; int countryID; if (!Int32.TryParse(_country, out countryID)) { return(Content("Country Id is not set")); } int top; if (!Int32.TryParse(_top, out top)) { return(Content("Top is not set")); } DateTime from = new DateTime(); if (!DateTime.TryParse(_from, out from)) { return(Content("Cannot parse from date!")); } DateTime to = new DateTime(); if (!DateTime.TryParse(_to, out to)) { return(Content("Cannot parse to date!")); } Country country = new Country(countryID); List <AndroidPremiumCustomer> customer = AndroidPremiumCustomer.CreateManager().Load(from, to, country, top); ManagerModel model = new ManagerModel(); model.Customers = customer; if (model == null) { return(Content("Model is empty")); } return(PartialView("~/Views/Manager/Partials/_Customers.cshtml", model)); }
private AndroidPremiumCustomer GetCustomer(string uniqueID, string applicationName, string ipAddress, string msisdn, string referrer) { AndroidPremiumCustomer customer = AndroidPremiumCustomer.CreateManager().Load(uniqueID); if (customer != null) { return(customer); } AndroidPremiumAplication app = AndroidPremiumAplication.CreateManager().Load(applicationName); if (app == null) { app = new AndroidPremiumAplication(-1, applicationName, DateTime.Now, DateTime.Now); app.Insert(); } if (ipAddress == "::1") { ipAddress = "62.4.59.218"; } IIPCountryMapManager ipcmManager = IPCountryMap.CreateManager(); IPCountryMap countryMap = ipcmManager.Load(ipAddress); if (countryMap == null || countryMap.Country == null) { Log.Fatal("Could not load Country by ID:" + ipAddress); return(null); } customer = new AndroidPremiumCustomer(-1, uniqueID, app, countryMap.Country, ipAddress, msisdn, referrer, DateTime.Now, DateTime.Now); customer.Insert(); return(customer); }