mirror of
https://git.teknik.io/Teknikode/Teknik.git
synced 2023-08-02 14:16:22 +02:00
Made subscription page data driven
This commit is contained in:
parent
84e41499be
commit
c397365d33
@ -10,6 +10,7 @@ using Teknik.Configuration;
|
||||
using Teknik.Controllers;
|
||||
using Teknik.Data;
|
||||
using Teknik.Logging;
|
||||
using Teknik.Utilities.Routing;
|
||||
|
||||
namespace Teknik.Areas.Billing.Controllers
|
||||
{
|
||||
@ -27,7 +28,110 @@ namespace Teknik.Areas.Billing.Controllers
|
||||
[AllowAnonymous]
|
||||
public IActionResult Subscriptions()
|
||||
{
|
||||
return View(new BillingViewModel() { StripePublishKey = _config.BillingConfig.StripePublishApiKey });
|
||||
var subVM = new SubscriptionsViewModel();
|
||||
|
||||
// Get Upload Subscriptions
|
||||
subVM.UploadSubscriptions.Add(new SubscriptionViewModel()
|
||||
{
|
||||
SubscriptionId = "upload_free",
|
||||
SubscriptionName = "Basic Account",
|
||||
SubscribeText = "Sign up for free",
|
||||
SubscribeUrl = Url.SubRouteUrl("account", "User.Register"),
|
||||
BaseStorage = 5368709120,
|
||||
MaxStorage = 107374200000
|
||||
});
|
||||
subVM.UploadSubscriptions.Add(new SubscriptionViewModel()
|
||||
{
|
||||
Primary = true,
|
||||
SubscriptionId = "upload_10gb",
|
||||
SubscriptionName = "Standalone 10 GB",
|
||||
SubscribeText = "Subscribe",
|
||||
SubscribeUrl = Url.SubRouteUrl("billing", "Billing.Subscribe", new { subscription = "upload_10gb" }),
|
||||
BaseStorage = 10737418240,
|
||||
BasePrice = 0.99,
|
||||
BaseUnit = "month",
|
||||
OverageAllowed = true,
|
||||
OveragePrice = 0.30,
|
||||
OverageUnit = "GB",
|
||||
MaxStorage = 107374200000
|
||||
});
|
||||
subVM.UploadSubscriptions.Add(new SubscriptionViewModel()
|
||||
{
|
||||
Primary = true,
|
||||
SubscriptionId = "upload_50gb",
|
||||
SubscriptionName = "Standalone 50 GB",
|
||||
SubscribeText = "Subscribe",
|
||||
SubscribeUrl = Url.SubRouteUrl("billing", "Billing.Subscribe", new { subscription = "upload_50gb" }),
|
||||
BaseStorage = 53687091200,
|
||||
BasePrice = 3.99,
|
||||
BaseUnit = "month",
|
||||
OverageAllowed = true,
|
||||
OveragePrice = 0.30,
|
||||
OverageUnit = "GB",
|
||||
MaxStorage = 107374200000
|
||||
});
|
||||
subVM.UploadSubscriptions.Add(new SubscriptionViewModel()
|
||||
{
|
||||
Primary = true,
|
||||
SubscriptionId = "upload_usage",
|
||||
SubscriptionName = "Pay Per Unit",
|
||||
SubscribeText = "Subscribe",
|
||||
SubscribeUrl = Url.SubRouteUrl("billing", "Billing.Subscribe", new { subscription = "upload_usage" }),
|
||||
BaseStorage = null,
|
||||
BasePrice = 0.15,
|
||||
BaseUnit = "GB",
|
||||
OverageAllowed = true,
|
||||
OverageUnit = "monthly",
|
||||
MaxStorage = 107374200000
|
||||
});
|
||||
|
||||
// Get Email Subscriptions
|
||||
subVM.EmailSubscriptions.Add(new SubscriptionViewModel()
|
||||
{
|
||||
Primary = true,
|
||||
SubscriptionId = "email_1gb_monthly",
|
||||
SubscriptionName = "Basic Email - Monthly",
|
||||
SubscribeText = "Subscribe",
|
||||
SubscribeUrl = Url.SubRouteUrl("billing", "Billing.Subscribe", new { subscription = "email_1gb_monthly" }),
|
||||
BaseStorage = 1073741824,
|
||||
BasePrice = 1.99,
|
||||
BaseUnit = "month"
|
||||
});
|
||||
subVM.EmailSubscriptions.Add(new SubscriptionViewModel()
|
||||
{
|
||||
Primary = true,
|
||||
SubscriptionId = "email_1gb_yearly",
|
||||
SubscriptionName = "Basic Email - Yearly",
|
||||
SubscribeText = "Subscribe",
|
||||
SubscribeUrl = Url.SubRouteUrl("billing", "Billing.Subscribe", new { subscription = "email_1gb_yearly" }),
|
||||
BaseStorage = 1073741824,
|
||||
BasePrice = 19.99,
|
||||
BaseUnit = "year"
|
||||
});
|
||||
subVM.EmailSubscriptions.Add(new SubscriptionViewModel()
|
||||
{
|
||||
Primary = true,
|
||||
SubscriptionId = "email_5gb_monthly",
|
||||
SubscriptionName = "Premium Email - Monthly",
|
||||
SubscribeText = "Subscribe",
|
||||
SubscribeUrl = Url.SubRouteUrl("billing", "Billing.Subscribe", new { subscription = "email_5gb_monthly" }),
|
||||
BaseStorage = 5368709120,
|
||||
BasePrice = 3.99,
|
||||
BaseUnit = "month"
|
||||
});
|
||||
subVM.EmailSubscriptions.Add(new SubscriptionViewModel()
|
||||
{
|
||||
Primary = true,
|
||||
SubscriptionId = "email_5gb_yearly",
|
||||
SubscriptionName = "Premium Email - Yearly",
|
||||
SubscribeText = "Subscribe",
|
||||
SubscribeUrl = Url.SubRouteUrl("billing", "Billing.Subscribe", new { subscription = "email_5gb_yearly" }),
|
||||
BaseStorage = 5368709120,
|
||||
BasePrice = 39.99,
|
||||
BaseUnit = "year"
|
||||
});
|
||||
|
||||
return View(subVM);
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
|
30
Teknik/Areas/Billing/ViewModels/SubscriptionViewModel.cs
Normal file
30
Teknik/Areas/Billing/ViewModels/SubscriptionViewModel.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Teknik.ViewModels;
|
||||
|
||||
namespace Teknik.Areas.Billing.ViewModels
|
||||
{
|
||||
public class SubscriptionViewModel : ViewModelBase
|
||||
{
|
||||
public bool Primary { get; set; }
|
||||
public string SubscriptionId { get; set; }
|
||||
public string SubscriptionName { get; set; }
|
||||
public double? BasePrice { get; set; }
|
||||
public string BaseUnit { get; set; }
|
||||
public long? BaseStorage { get; set; }
|
||||
public bool OverageAllowed { get; set; }
|
||||
public double? OveragePrice { get; set; }
|
||||
public string OverageUnit { get; set; }
|
||||
public long? MaxStorage { get; set; }
|
||||
public string SubscribeUrl { get; set; }
|
||||
public string SubscribeText { get; set; }
|
||||
|
||||
public SubscriptionViewModel()
|
||||
{
|
||||
Primary = false;
|
||||
OverageAllowed = false;
|
||||
}
|
||||
}
|
||||
}
|
20
Teknik/Areas/Billing/ViewModels/SubscriptionsViewModel.cs
Normal file
20
Teknik/Areas/Billing/ViewModels/SubscriptionsViewModel.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Teknik.ViewModels;
|
||||
|
||||
namespace Teknik.Areas.Billing.ViewModels
|
||||
{
|
||||
public class SubscriptionsViewModel : ViewModelBase
|
||||
{
|
||||
public List<SubscriptionViewModel> UploadSubscriptions { get; set; }
|
||||
public List<SubscriptionViewModel> EmailSubscriptions { get; set; }
|
||||
|
||||
public SubscriptionsViewModel()
|
||||
{
|
||||
UploadSubscriptions = new List<SubscriptionViewModel>();
|
||||
EmailSubscriptions = new List<SubscriptionViewModel>();
|
||||
}
|
||||
}
|
||||
}
|
47
Teknik/Areas/Billing/Views/Billing/Subscription.cshtml
Normal file
47
Teknik/Areas/Billing/Views/Billing/Subscription.cshtml
Normal file
@ -0,0 +1,47 @@
|
||||
@model Teknik.Areas.Billing.ViewModels.SubscriptionViewModel
|
||||
|
||||
@{
|
||||
var extraUsage = "";
|
||||
if (Model.MaxStorage != null)
|
||||
extraUsage = $"If you need more than {StringHelper.GetBytesReadable(Model.MaxStorage.Value)} of storage, please contact support for assistance.";
|
||||
var panelColor = "info";
|
||||
if (Model.Primary)
|
||||
panelColor = "primary";
|
||||
|
||||
var price = Model.BasePrice.HasValue ? $"${Model.BasePrice:0.00} <small>/ {Model.BaseUnit}</small>" : "Free";
|
||||
var overage = "No Overage Allowed";
|
||||
if (Model.OverageAllowed)
|
||||
{
|
||||
overage = "No Overage Fee";
|
||||
if (Model.OveragePrice != null)
|
||||
{
|
||||
overage = $"Overage at ${Model.OveragePrice:0.00} / {Model.OverageUnit}";
|
||||
if (Model.MaxStorage != null)
|
||||
overage += $" <span data-toggle=\"tooltip\" data-placement=\"top\" title=\"{extraUsage}\">(Up to {StringHelper.GetBytesReadable(Model.MaxStorage.Value)})*</span>";
|
||||
}
|
||||
}
|
||||
var storageAllowed = "";
|
||||
if (Model.BaseStorage != null)
|
||||
{
|
||||
storageAllowed = $"<strong>{StringHelper.GetBytesReadable(Model.BaseStorage.Value)}</strong> Storage";
|
||||
}
|
||||
else if (Model.MaxStorage != null)
|
||||
{
|
||||
storageAllowed = $"<strong><span data-toggle=\"tooltip\" data-placement=\"top\" title=\"{extraUsage}\">Up to {StringHelper.GetBytesReadable(Model.MaxStorage.Value)}*</span></strong> Storage";
|
||||
}
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<div class="panel panel-@panelColor">
|
||||
<div class="panel-heading">
|
||||
<h2 class="panel-title">@Model.SubscriptionName</h2>
|
||||
</div>
|
||||
<div class="panel-body text-center">
|
||||
<h2>@Html.Raw(price)</h2>
|
||||
<h5>
|
||||
<small>@Html.Raw(overage)</small>
|
||||
</h5>
|
||||
<p>@Html.Raw(storageAllowed)</p>
|
||||
<p><a href="@Model.SubscribeUrl" class="btn btn-primary center-block" role="button">@Model.SubscribeText</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
@ -1,89 +1,50 @@
|
||||
@model Teknik.Areas.Billing.ViewModels.BillingViewModel
|
||||
@model Teknik.Areas.Billing.ViewModels.SubscriptionsViewModel
|
||||
|
||||
@{
|
||||
string extraUsage = "If you need more than 100 GB of monthly upload bandwidth, please contact support for assistance.";
|
||||
string extraUsage = null;
|
||||
}
|
||||
|
||||
<div class="container">
|
||||
<h2 class="text-center">Upload Bandwidth Subscriptions</h2>
|
||||
<br />
|
||||
<div class="row">
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<div class="panel panel-info">
|
||||
<div class="panel-heading">
|
||||
<h2 class="panel-title">Basic Account</h2>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<h2>Free</h2>
|
||||
<h5>
|
||||
<small>No Overage Allowed</small>
|
||||
</h5>
|
||||
@if (Model.UploadSubscriptions.Any())
|
||||
{
|
||||
<h2 class="text-center">Upload Storage Subscriptions</h2>
|
||||
<br />
|
||||
<div class="row">
|
||||
@foreach (var subVM in Model.UploadSubscriptions)
|
||||
{
|
||||
if (subVM.MaxStorage != null)
|
||||
extraUsage = $"If you need more than {StringHelper.GetBytesReadable(subVM.MaxStorage.Value)} of storage, please contact support for assistance.";
|
||||
|
||||
@await Html.PartialAsync("../../Areas/Billing/Views/Billing/Subscription", subVM)
|
||||
}
|
||||
</div>
|
||||
@if (!string.IsNullOrEmpty(extraUsage))
|
||||
{
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<p>
|
||||
<strong>5 GB</strong> Uploads <small class="text-muted">/ month</small>
|
||||
<small>
|
||||
* @extraUsage
|
||||
</small>
|
||||
</p>
|
||||
<p><a href="@Url.SubRouteUrl("account", "User.Register")" class="btn btn-primary center-block" role="button">Sign up for free</a></p>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
@if (Model.EmailSubscriptions.Any())
|
||||
{
|
||||
<br />
|
||||
<h2 class="text-center">Email Subscriptions</h2>
|
||||
<br />
|
||||
<div class="row">
|
||||
@foreach (var subVM in Model.EmailSubscriptions)
|
||||
{
|
||||
if (subVM.MaxStorage != null)
|
||||
extraUsage = $"If you need more than {StringHelper.GetBytesReadable(subVM.MaxStorage.Value)} of storage, please contact support for assistance.";
|
||||
|
||||
@await Html.PartialAsync("../../Areas/Billing/Views/Billing/Subscription", subVM)
|
||||
}
|
||||
</div>
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<h2 class="panel-title">Standalone 10 GB</h2>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<h2>$0.99 <small>/ month</small></h2>
|
||||
<h5>
|
||||
<small>Overage at $0.30 / GB <span data-toggle="tooltip" data-placement="top" title="@extraUsage">(Up to 100 GB)*</span></small>
|
||||
</h5>
|
||||
<p>
|
||||
<strong>10 GB</strong> Uploads <small class="text-muted">/ month</small>
|
||||
</p>
|
||||
<p><a href="@Url.SubRouteUrl("billing", "Billing.Subscribe", new { plan = "10gb" })" class="btn btn-primary center-block" role="button">Subscribe</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<h2 class="panel-title">Standalone 50 GB</h2>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<h2>$3.99 <small>/ month</small></h2>
|
||||
<h5>
|
||||
<small>Overage at $0.30 / GB <span data-toggle="tooltip" data-placement="top" title="@extraUsage">(Up to 100 GB)*</span></small>
|
||||
</h5>
|
||||
<p>
|
||||
<strong>50 GB</strong> Uploads <small class="text-muted">/ month</small>
|
||||
</p>
|
||||
<p><a href="@Url.SubRouteUrl("billing", "Billing.Subscribe", new { plan = "50gb" })" class="btn btn-primary center-block" role="button">Subscribe</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-md-3">
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<h2 class="panel-title">By Upload Usage</h2>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<h2>$0.15 <small>/ GB</small></h2>
|
||||
<h5>
|
||||
<small>No Overage Fee</small>
|
||||
</h5>
|
||||
<p>
|
||||
<strong><span data-toggle="tooltip" data-placement="top" title="@extraUsage">Up to 100 GB*</span></strong> Uploads <small class="text-muted">/ month</small>
|
||||
</p>
|
||||
<p><a href="@Url.SubRouteUrl("billing", "Billing.Subscribe", new { plan = "usage" })" class="btn btn-primary center-block" role="button">Subscribe</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<p>
|
||||
<small>
|
||||
* @extraUsage
|
||||
</small>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user