public ActionResult SubscriptionModule(SubscriptionModel model) { if (ModelState.IsValid) { model.Subscribed = true; var entity = model.ToEntity(); _emailSubscriptionService.Add(entity); model.EmailAddress = ""; } return(PartialView(model)); }
public void Delete(Guid id) { SubscriptionModel subscription = context.Subscriptions.FirstOrDefault(u => u.Id == id); if (subscription != null) { subscription.Enabled = false; Update(subscription); } }
/// <inheritdoc/> public Task <ISubscription> GetOrCreateSubscriptionAsync(SubscriptionModel subscriptionModel) { if (string.IsNullOrEmpty(subscriptionModel?.Id)) { throw new ArgumentNullException(nameof(subscriptionModel)); } var sub = _subscriptions.GetOrAdd(subscriptionModel.Id, key => new SubscriptionWrapper(this, subscriptionModel, _logger)); return(Task.FromResult <ISubscription>(sub)); }
public async Task SnowfallMayNotBeSpecifiedInInvalidUnits() { const string userId = "42"; var subscription = new SubscriptionModel(userId, "http://www.snow-forecast.com/resorts/Alta"); var subscriptionRepo = new SubscriptionRepository(null); await new SubscribeStrategy(new UserModel(userId), new string[] { "subscribe", subscription.Uri, "10asd" }, subscriptionRepo) .Process(); }
public static Subscription ToDomain(this SubscriptionModel sub) { return(new Subscription { CaptureDateTime = sub.CaptureDateTime, CreationDateTime = sub.CreationDateTime, EventName = sub.EventName, CasePlanElementInstanceId = sub.CasePlanElementInstanceId, CasePlanInstanceId = sub.CasePlanInstanceId, IsCaptured = sub.IsCaptured }); }
/// <summary> /// Handles the Show view request. /// </summary> /// <param name="customerId">The customer identifier.</param> /// <param name="subscriptionId">The subscription identifier.</param> /// <returns>Returns either the Azure or Office subscription view.</returns> /// <exception cref="System.ArgumentNullException"> /// customerId /// or /// subscriptionId /// </exception> /// <remarks> /// If the subscription's billing type is usage then the Office view is returned. /// Otherwise, the Azure view is returned. /// </remarks> public async Task <ActionResult> Show(string customerId, string subscriptionId) { Customer customer; IAggregatePartner operations; Subscription subscription; SubscriptionModel model; if (string.IsNullOrEmpty(customerId)) { throw new ArgumentNullException(nameof(customerId)); } if (string.IsNullOrEmpty(subscriptionId)) { throw new ArgumentNullException(nameof(subscriptionId)); } try { operations = await new SdkContext().GetPartnerOperationsAysnc(); customer = await operations.Customers.ById(customerId).GetAsync(); subscription = await operations.Customers.ById(customerId).Subscriptions.ById(subscriptionId).GetAsync(); model = new SubscriptionModel() { AutoRenewEnabled = subscription.AutoRenewEnabled, BillingType = subscription.BillingType, CommitmentEndDate = subscription.CommitmentEndDate, CompanyName = customer.CompanyProfile.CompanyName, CreationDate = subscription.CreationDate, CustomerId = customerId, EffectiveStartDate = subscription.EffectiveStartDate, FriendlyName = subscription.FriendlyName, Id = subscription.Id, OfferId = subscription.OfferId, OfferName = subscription.OfferName, ParentSubscriptionId = subscription.ParentSubscriptionId, PartnerId = subscription.PartnerId, Quantity = subscription.Quantity, Status = subscription.Status, SuspensionReasons = subscription.SuspensionReasons, UnitType = subscription.UnitType, ViewModel = (subscription.BillingType == BillingType.License) ? "Office" : "Azure" }; return(View(model.ViewModel, model)); } finally { customer = null; subscription = null; } }
public void AddToCart(SubscriptionModel subModel) { if (_listSubscription.ContainsKey(subModel.id)) { _listSubscription[subModel.id].quantity++; } else { _listSubscription.Add(subModel.id, subModel); } UpdateTotalMoney(); }
public static Domain.Models.Subscription Map(SubscriptionModel model) { return(new Domain.Models.Subscription { Subscriber = new Domain.Models.User { ID = model.Subscriber.ID, Name = model.Publisher.Name }, Publisher = new Domain.Models.User { ID = model.Publisher.ID, Name = model.Publisher.Name }, HasNewContent = model.HasNewContent }); }
public ActionResult SubscribeBox(SubscriptionModel model) { if (ModelState.IsValid) { var result = _accountService.ProcessNewEmailSubscription(model.Email); return(RedirectToRoute("Subscription Result", new { resultId = (int)result })); } else { return(RedirectToRoute("Subscription Result", new { resultId = (int)SubscriptionResults.InvalidEmail })); } }
private SubscriptionDescription GenerateSubscriptionDescription(SubscriptionModel subscriptionRequest) { SubscriptionDescription subscriptionDescription = new SubscriptionDescription(subscriptionRequest.TopicName, subscriptionRequest.Name); subscriptionDescription.DefaultMessageTimeToLive = new TimeSpan(0, 0, 0, Convert.ToInt32(subscriptionRequest.DefaultMessageTime, CultureInfo.InvariantCulture)); subscriptionDescription.LockDuration = new TimeSpan(0, 0, Convert.ToInt32(subscriptionRequest.LockDuration, CultureInfo.InvariantCulture)); subscriptionDescription.MaxDeliveryCount = Convert.ToInt32(subscriptionRequest.MaxDeliveryCount, CultureInfo.InvariantCulture); subscriptionDescription.EnableDeadLetteringOnMessageExpiration = subscriptionRequest.MoveExpiredToDLQ; subscriptionDescription.EnableDeadLetteringOnFilterEvaluationExceptions = subscriptionRequest.EnableDeadLetteringOnFilterEvaluationExceptions; subscriptionDescription.RequiresSession = subscriptionRequest.EnableSessions; return(subscriptionDescription); }
public async Task <ActionResult> Success(string session_id) { var user = await _adminRepository.GetUserAsync(CurrentUser); SubscriptionModel subscriptionModel = SubscribeService.Success(session_id, CurrentCompany); user.SubscriptionId = subscriptionModel.SubscriptionId; user.SubsciptionStatus = subscriptionModel.SubsciptionStatus; await _adminRepository.UpdateUserAsync(user); return(RedirectToAction("Index", "AdminSubscription", new { message = "You subscribed successfully" })); }
public async Task Subscribe(Instrument instr, SubscriptionModel model) { if (instr == null) { _logger.Log(LogPriority.Error, "instrument not specified", Name); _client.OnEvent(Name, BrokerEvent.CoinSubscribedFault, string.Empty); throw new ArgumentNullException("instrument not specified"); } if (IsConnected != true) { _logger.Log(LogPriority.Error, $"Subscribe: {Name} is not connected", Name); _client.OnEvent(Name, BrokerEvent.CoinSubscribedFault, instr.Id()); throw new Exception($"{Name} is not connected"); } var symbol = Utilities.GDAXSymbol(instr); using (await _lock.LockAsync()) { if (!SubscribeList.ContainsKey(symbol)) { if (model == SubscriptionModel.TopBook) { var request = new { type = "subscribe", product_ids = new List <string>() { symbol }, channels = new List <string>() { "ticker" }, }; SubscribeList.Add(symbol, new Subscribe() { pair = instr }); _client.OnEvent(Name, BrokerEvent.CoinSubscribed, symbol); string paramData = JsonConvert.SerializeObject(request, Formatting.Indented); await chnl.SendCommand(Encoding.UTF8.GetBytes(paramData)); } } else { _client.OnEvent(Name, BrokerEvent.CoinSubscribedFault, "Subscribe on " + symbol + " already created"); } } }
public ActionResult Create([Bind(Exclude = "Id")] SubscriptionModel model) { ActionResult view = View(); try { model.Callback = model.Callback ?? Request.Url.GetLeftPart(UriPartial.Authority) + GetAppPath() + Url.Action("HubUpdate", "HubSubscription"); model.Mode = model.Mode ?? "subscribe"; model.Verify = model.Verify ?? "sync"; model.PubSubHubUser = HubConfiguration.HubUsername; _loggingService.Info("Creating subscription for " + model + "\nModel valid: " + ViewData.ModelState.IsValid); ViewData.Model = model; if (ViewData.ModelState.IsValid) { int maxSubsForUser = _subscriptionPersistenceService.GetMaxSubscriptionsForUser(model.PubSubHubUser); int userSubCount = _subscriptionPersistenceService.GetSubscriptionCountForUser(model.PubSubHubUser); if (userSubCount >= maxSubsForUser) { string msg = string.Format("Maximum number of subscriptions reaced for user. Subscriptions in use {0}. Maximum subscriptions {1}.", userSubCount, maxSubsForUser); ViewData["ErrorDescription"] = msg; } else { _subscriptionPersistenceService.StoreSubscription(model); SubscriptionServiceResult result = _subscriptionService.Subscribe(HubConfiguration, model); if (result.Type != SubscriptionResponseResultType.Success) { ViewData["ErrorDescription"] = result.ErrorDescription; } else { view = RedirectToAction("Index"); } } } } catch (Exception ex) { string msg = "An exception occurred in Create method: " + ex.ToString(); _loggingService.Error(msg); ViewData["ErrorDescription"] = msg; } return(view); }
public virtual async Task <IActionResult> Edit(SubscriptionModel skuModel) { var updateResult = await this.subscriptionManager.UpdateSubscriptionWithAdminNameAsync(this.User.Identity.Name, skuModel.CurrentSku.Id); if (!updateResult.Succeeded) { return(this.ErrorAndRedirectHome("Cannot cancel subscription")); } return(this.Redirect("/")); }
public SubscriptionModel ToSubscriptionModel() { SubscriptionModel sm = new SubscriptionModel() { AccessLevel_Binder = AccessLevel, AccountGuid = AccountGuid, Name = "Default Subscription", SubscriptionId = SubscriptionId, SubscriptionGuid = SubscriptionGuid }; return(sm); }
public void OnSubscribeToEvent(SubscriptionModel model, Delegate callback) { var transport = new TransportModel() { Contract = model.Contract, Identifier = Guid.NewGuid(), Type = TransportType.Event, EventHandler = model.EventHandler }; m_ActiveSubscriptions.Add(transport.Identifier, callback); TelepathyClient.Send(SerializeTransport(transport)); }
public async Task <SubscriptionModel> SubscribeChannel(User user, ChannelModel channel) { var temp = new SubscriptionModel { User = user, Channel = channel }; _context.Subscriptions.Add(temp); await _context.SaveChangesAsync(); return(temp); }
/// <summary> /// Subscription wrapper /// </summary> /// <param name="outer"></param> /// <param name="subscription"></param> /// <param name="logger"></param> public SubscriptionWrapper(SubscriptionServices outer, SubscriptionModel subscription, ILogger logger) { _subscription = subscription.Clone() ?? throw new ArgumentNullException(nameof(subscription)); _outer = outer ?? throw new ArgumentNullException(nameof(outer)); _logger = logger?.ForContext <SubscriptionWrapper>() ?? throw new ArgumentNullException(nameof(logger)); _timer = new Timer(_ => OnCheckAsync().Wait()); _lock = new SemaphoreSlim(1, 1); }
public static DateTimeOffset?ResolveStartDate(DateTime transactionDate, SubscriptionModel previousSub) { if (previousSub == null) { return(new DateTimeOffset(transactionDate)); } // Weird hack to account for transaction time being slightly later than start date for a subscription purchase. My systems are bad and I should feel bad if (transactionDate >= previousSub.StartDateTime.AddMinutes(10)) { return(previousSub.StartDateTime.AddMonths(1)); } return(null); }
public static Subscription ToDomain(this SubscriptionModel sub) { return(new Subscription { CaptureDateTime = sub.CaptureDateTime, CreationDateTime = sub.CreationDateTime, EventName = sub.EventName, CasePlanElementInstanceId = sub.CasePlanElementInstanceId, CasePlanInstanceId = sub.CasePlanInstanceId, IsCaptured = sub.IsCaptured, Parameters = string.IsNullOrEmpty(sub.Parameters) ? new Dictionary <string, string>() : JsonConvert.DeserializeObject <Dictionary <string, string> > (sub.Parameters) }); }
// Create entity from model. public Subscription(SubscriptionModel model) { Id = model.Id; CanonicalName = model.CanonicalName; DisplayName = model.DisplayName; Description = model.Description; Price = model.Price; IsExpired = model.IsExpired; PromotionCode = model.PromotionCode; RenewalOccurrence = model.RenewalOccurrence; RenewalTimeframe = model.RenewalTimeframe == null ? null : new SystemLookupItemValue(model.RenewalTimeframe); Highlights = model.Highlights; }
public void UpdatedTodayTest(int gmt, bool expected) { var user = new UserModel("42") { Gmt = gmt }; var now = new DateTimeOffset(2017, 10, 10, 16, 0, 0, new TimeSpan()); var sub = new SubscriptionModel { Timestamp = now }; Assert.AreEqual(expected, sub.UpdatedToday(user, now)); }
public int update(SubscriptionModel subscriptionModel) { tblSubscription tblSubscriptionDb = new tblSubscription(); tblSubscriptionDb.SubscriptionId = subscriptionModel.SubscriptionId; tblSubscriptionDb.SubscriptionName = subscriptionModel.SubscriptionName; tblSubscriptionDb.Validity = subscriptionModel.Validity; tblSubscriptionDb.AllowedUser = subscriptionModel.AllowedUser; tblSubscriptionDb.IsSmsForAlert = subscriptionModel.IsSmsForAlert; tblSubscriptionDb.IsSmsForReminder = subscriptionModel.IsSmsForReminder; tblSubscriptionDb.Status = subscriptionModel.Status; if (subscriptionModel.SubscriptionId > 0) { tblSubscriptionDb.ModifiedBy = AdminSessionData.AdminUserId; tblSubscriptionDb.ModifiedOn = DateTime.Now; tblSubscriptionDb.ModifiedFromIP = HttpContext.Current.Request.UserHostAddress; context.tblSubscriptions.Attach(tblSubscriptionDb); context.Entry(tblSubscriptionDb).Property(x => x.SubscriptionName).IsModified = true; context.Entry(tblSubscriptionDb).Property(x => x.Validity).IsModified = true; context.Entry(tblSubscriptionDb).Property(x => x.AllowedUser).IsModified = true; context.Entry(tblSubscriptionDb).Property(x => x.IsSmsForAlert).IsModified = true; context.Entry(tblSubscriptionDb).Property(x => x.IsSmsForReminder).IsModified = true; context.Entry(tblSubscriptionDb).Property(x => x.Status).IsModified = true; context.Entry(tblSubscriptionDb).Property(x => x.ModifiedBy).IsModified = true; context.Entry(tblSubscriptionDb).Property(x => x.ModifiedOn).IsModified = true; context.Entry(tblSubscriptionDb).Property(x => x.ModifiedFromIP).IsModified = true; } else { tblSubscriptionDb.CreatedBy = AdminSessionData.AdminUserId; tblSubscriptionDb.CreatedOn = DateTime.Now; tblSubscriptionDb.CreatedFromIP = HttpContext.Current.Request.UserHostAddress; context.tblSubscriptions.Add(tblSubscriptionDb); } int count = context.SaveChanges(); if (count == 1) { count = 0; } else { count = -1; } return(count); }
public void AddSubscription(SubscriptionModel model) { try { var content = new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json"); var result = _http.PostAsync(_baseUri, content).Result; result.EnsureSuccessStatusCode(); } catch (Exception ex) { _logger.LogError($"Failed to add subscription.", ex, model); throw; } }
// GET: SubscriptionModels/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SubscriptionModel subscriptionModel = await db.gg.FindAsync(id); if (subscriptionModel == null) { return(HttpNotFound()); } return(View(subscriptionModel)); }
// GET: SubscriptionModels/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SubscriptionModel subscriptionModel = _repo.FindBy(id); if (subscriptionModel == null) { return(HttpNotFound()); } return(View(subscriptionModel)); }
public static string SubscriptionVerification(string cellPhone, string token) { string isSubscribed = string.Empty; string msidsdn = cellPhone; var model = new SubscriptionModel(); if (msidsdn.Substring(0, 1) == "0") { msidsdn = "+27" + msidsdn.Substring(1); } if (!String.IsNullOrWhiteSpace(msidsdn)) { using (var http = new HttpClient()) { var url = $"baseUrl/customers/{msidsdn}/subscriptions"; http.DefaultRequestHeaders.Add("Authorization", String.Format("Bearer {0}", token)); var response = http.GetAsync(url); var request = response.Result.Content.ReadAsStringAsync().Result; var jsonResult = request.TrimStart(new char[] { '[' }).TrimEnd(new char[] { ']' }); JObject jObject = JObject.Parse(jsonResult); model.Subscription_Id = Convert.ToString(jObject.SelectToken("id")); model.SubscriptionTypeId = Convert.ToString(jObject.SelectToken("subscriptionTypeId")); model.CustomerId = Convert.ToString(jObject.SelectToken("customerId")); model.ValidFrom = Convert.ToString(jObject.SelectToken("validFrom")); model.ValidTo = Convert.ToString(jObject.SelectToken("validTo")); model.CancelledDate = Convert.ToString(jObject.SelectToken("validFrom")); model.CancelledReason = Convert.ToString(jObject.SelectToken("validTo")); model.CreatedAt = Convert.ToString(jObject.SelectToken("validFrom")); model.UpdatedAt = Convert.ToString(jObject.SelectToken("validTo")); if (!String.IsNullOrWhiteSpace(model.Subscription_Id) && !String.IsNullOrWhiteSpace(model.SubscriptionTypeId)) { BusinessLogic.TokenRepositary.InsertSubscriptionDetails(cellPhone, model.Subscription_Id, model.SubscriptionTypeId, model.CustomerId, model.ValidFrom, model.ValidTo, model.CancelledDate, model.CancelledReason, model.CreatedAt, model.UpdatedAt, baseUrl); return(isSubscribed = $"Subscription already exist for cellphone number: {msidsdn}"); } else { return(isSubscribed = $"No subcription found for cellphone number: {msidsdn}"); } } } return(isSubscribed); }
public async Task <string> Subscribe(SubscriptionModel subscriptionModel) { var getApiKeysResponse = await GetApiKeysRequest(subscriptionModel.IdentityId); if (getApiKeysResponse.Items.Any()) { return(getApiKeysResponse.Items.First().Value); } var createApiKeyResponse = await CreateApiKeyRequest(subscriptionModel.IdentityId); await CreateUsagePlanKey(createApiKeyResponse.Id, subscriptionModel.UsagePlanId); return(createApiKeyResponse.Value); }
public Subscribe(Instrument instr, SubscriptionModel model) { this.pair = instr; this.mode = model; this.Id = instr.Id(); switch (model) { case SubscriptionModel.TopBook: { this.request = new TickerRequest(Utils.BittrexSymbol(instr)); market = new Market(); break; } } }
public IActionResult Subscribe([FromBody] SubscriptionModel subscribeModel) { if (!ModelState.IsValid) { return(BadRequest(new ResponseResult { IsOk = false, Description = "Не передан url или данные для авторизации" })); } return(BadRequest(new ResponseResult { IsOk = false, Description = "Метод еще не реализован" })); }
public SubscriptionModel Put(string id, SubscriptionModel model) { var retorno = PutAsync<SubscriptionModel>(id, model).Result; return retorno; }