Skip to content

Commit

Permalink
Got the new client page working in support of #195.
Browse files Browse the repository at this point in the history
  • Loading branch information
uncheckederror committed Jul 11, 2021
1 parent 7968971 commit a22143b
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 268 deletions.
25 changes: 22 additions & 3 deletions NumberSearch.Mvc/Controllers/NewClientController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;

using NumberSearch.DataAccess;
using NumberSearch.Mvc.Models;

using System;
using System.Collections.Generic;
Expand All @@ -11,11 +13,28 @@ namespace NumberSearch.Mvc.Controllers
{
public class NewClientController : Controller
{
[HttpGet("Cart/Order/{orderId}")]
private readonly IConfiguration _configuration;
private readonly string _postgresql;

public NewClientController(IConfiguration config)
{
_configuration = config;
_postgresql = _configuration.GetConnectionString("PostgresqlProd");
}

[HttpGet("Cart/Order/{orderId}/NewClient")]
[ResponseCache(VaryByHeader = "User-Agent", Duration = 30, Location = ResponseCacheLocation.Any)]
public IActionResult Index(Guid orderId)
public async Task<IActionResult> IndexAsync(Guid orderId)
{
return View();
var order = await Order.GetByIdAsync(orderId, _postgresql);

var form = new NewClientResult
{
Order = order,
NewClient = new NewClient()
};

return View("Index", form);
}


Expand Down
15 changes: 15 additions & 0 deletions NumberSearch.Mvc/Models/NewClientResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using NumberSearch.DataAccess;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace NumberSearch.Mvc.Models
{
public class NewClientResult
{
public NewClient NewClient { get; set; }
public Order Order { get; set; }
}
}
312 changes: 47 additions & 265 deletions NumberSearch.Mvc/Views/NewClient/Index.cshtml
Original file line number Diff line number Diff line change
@@ -1,281 +1,63 @@
@model NumberSearch.Mvc.Models.LookupResults;
@model NumberSearch.Mvc.Models.NewClientResult;

@{
ViewData["Title"] = "Bulk";
ViewData["Title"] = "New Client";
Layout = "~/Views/Shared/_Layout.cshtml";
}

<div class="container">
<br />
<div class="pricing-header mx-auto p-2 text-center">
<h1 class="display-4">Bulk Phone Numbers</h1>
<h1 class="display-4">New Client Setup</h1>
</div>
<br />
<div class="jumbotron mb-3 shadow">
<p> Enter a list of phone numbers and we'll hunt down any information we can find on it or check if we can port them to our network.</p>
<form class="form-row justify-content-center">
<div class="form-group">
<div class="input-group mx-auto input-group-lg">
<div class="input-group-prepend">
<span class="input-group-text">+1</span>
</div>
<textarea class="form-control" aria-label="With textarea" type="text" name="dialedNumber" placeholder="Enter Phone Numbers">@Model?.DialedNumber</textarea>
</div>
<div class="input-group mx-auto input-group-lg pt-2">
<button type="submit" class="btn btn-success btn-block" onclick="displayBusyIndicator()" asp-controller="Lookup" asp-action="Index">Investigate</button>
<button type="submit" class="btn btn-info btn-block" onclick="displayBusyIndicator()" asp-controller="Lookup" asp-action="BulkPort">Transfer</button>
</div>
</div>
</form>
</div>
<br />
<partial name="_LoadingPartial" />
<br />

<div class="row">
@{
if (Model != null && Model?.Lookups != null && Model.Lookups.Any())
{
<div class="table-responsive shadow-sm mb-4">
<table class="table table-striped table-hover table-borderless">
<thead>
<div class="col">
<p>Who will be using each phone? Does anyone need an extension without a phone (eg: Voicemail to email or Mobile/PC app only)? What is each user’s email address? Do you have any extensions currently?</p>
<div class="table-responsive">
<table class="table table-borderless table-hover table-striped">
<thead>
<tr>
<th>
Extension #
</th>
<th>
Name/Location
</th>
<th>
Email (Optional)
</th>
<th>
Model of Phone
</th>
<th>
Outbound Caller ID
</th>
</tr>
</thead>
<tbody>
@*@foreach (var number in Model?.NewClient?.ExtensionRegistrations)
{
<tr>
<th>
Phone Number
</th>
<th>
Last Port Date
</th>
<th>
Caller Name
</th>
<th>
Local Routing #
</th>
<th>
Carrier
</th>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</thead>
<tbody>
@{
foreach (var number in Model.Lookups)
{
<tr>
<td>
<h4>@number?.tn</h4>
</td>
<td>
@number?.LastPorted
</td>
<td>
@number?.LIDBName
</td>
<td>
<h4>@number?.lrn</h4>
</td>
<td>
<p>
@number?.spid
-
@number?.lec
-
@number?.lectype
</p>
</td>
</tr>
}
}
</tbody>
</table>
</div>
}
if (Model != null && Model?.NotPortable != null && Model.NotPortable.Any())
{
<div class="alert alert-danger col-12" role="alert">
These phone numbers cannot be ported to our network!
</div>
<div class="table-responsive shadow-sm">
<table class="table table-striped table-borderless table-hover">
<tbody>
@{
foreach (var number in Model.NotPortable)
{
<tr class="table-danger">
<td scope="row"><h4>@number</h4></td>
<td class="d-none d-sm-table-cell"></td>
<td class="d-none d-sm-table-cell"></td>
<td></td>
</tr>
}
}
</tbody>
</table>
</div>
}
if (Model != null && Model?.Portable != null && Model.Portable.Any())
{
var alreadyInCart = Model?.Cart?.PortedPhoneNumbers.ToDictionary(x => x?.PortedDialedNumber, x => x);
<div class="alert alert-success col-12" role="alert">
These phone numbers can be ported to our network and are now in your cart!
</div>
<div class="table-responsive shadow-sm mb-4">
<table class="table table-striped table-borderless table-hover">
<tbody>
@{
foreach (var number in Model.Portable)
{
var location = $"{number?.City ?? "Unknown City"}, {number?.State ?? "Unknown State"}";
var formattedNumber = $"({number.NPA}) {number.NXX}-{number.XXXX.ToString("0000")}";
<tr>
<td scope="row"><h4>@formattedNumber</h4></td>
<td class="d-none d-sm-table-cell">@Html.Raw(number.PortedDialedNumber)</td>
<td class="d-none d-sm-table-cell">@location</td>
<td></td>
<td>
@{
if (alreadyInCart.TryGetValue(number.PortedDialedNumber, out var _))
{
<button onclick="RemoveFromCart('PortedPhoneNumber', '@number.PortedDialedNumber', 1, this)" class="btn btn-outline-danger">Remove</button>
}
else
{
<button onclick="AddToCart('PortedPhoneNumber', '@number.PortedDialedNumber', 1, this)" class="btn btn-outline-primary">Add to Cart</button>
}
}
</td>
</tr>
<tr>
<th>
Phone Number
</th>
<th>
Last Port Date
</th>
<th>
Caller Name
</th>
<th>
Local Routing #
</th>
<th>
Carrier
</th>
</tr>
<tr>
<td>
<h4>@number?.LrnLookup?.tn</h4>
</td>
<td>
@number?.LrnLookup?.LastPorted
</td>
<td>
@number?.LrnLookup?.LIDBName
</td>
<td>
<h4>@number?.LrnLookup?.lrn</h4>
</td>
<td>
<p>
@number?.LrnLookup?.spid
-
@number?.LrnLookup?.lec
-
@number?.LrnLookup?.lectype
</p>
</td>
</tr>
}
}
</tbody>
</table>
</div>
}
if (Model != null && Model?.Wireless != null && Model.Wireless.Any())
{
var alreadyInCart = Model?.Cart?.PortedPhoneNumbers.ToDictionary(x => x?.PortedDialedNumber, x => x);
<div class="alert alert-success col-12" role="alert">
These wireless phone numbers can be ported to our network and are now in your cart!
</div>
<div class="table-responsive shadow-sm pb-4">
<table class="table table-striped table-borderless table-hover">
<tbody>
@{
foreach (var number in Model.Wireless)
{
var location = $"{number?.City ?? "Unknown City"}, {number?.State ?? "Unknown State"}";
var formattedNumber = $"({number.NPA}) {number.NXX}-{number.XXXX.ToString("0000")}";
<tr>
@{
if (number.Wireless)
{
<td class="d-none d-sm-table-cell">
<h4><span class="badge badge-warning">Wireless</span></h4>
</td>
}
}
<td scope="row"><h4>@formattedNumber</h4></td>
<td class="d-none d-sm-table-cell">@Html.Raw(number.PortedDialedNumber)</td>
<td class="d-none d-sm-table-cell">@location</td>
<td></td>
<td>
@{
if (alreadyInCart.TryGetValue(number.PortedDialedNumber, out var _))
{
<button onclick="RemoveFromCart('PortedPhoneNumber', '@number.PortedDialedNumber', 1, this)" class="btn btn-outline-danger">Remove</button>
}
else
{
<button onclick="AddToCart('PortedPhoneNumber', '@number.PortedDialedNumber', 1, this)" class="btn btn-outline-primary">Add to Cart</button>
}
}
</td>
</tr>
<tr>
<th>
Phone Number
</th>
<th>
Last Port Date
</th>
<th>
Caller Name
</th>
<th>
Local Routing #
</th>
<th>
Carrier
</th>
</tr>
<tr>
<td>
<h4>@number?.LrnLookup?.tn</h4>
</td>
<td>
@number?.LrnLookup?.LastPorted
</td>
<td>
@number?.LrnLookup?.LIDBName
</td>
<td>
<h4>@number?.LrnLookup?.lrn</h4>
</td>
<td>
<p>
@number?.LrnLookup?.spid
-
@number?.LrnLookup?.lec
-
@number?.LrnLookup?.lectype
</p>
</td>
</tr>
}
}
</tbody>
</table>
}*@
</tbody>
</table>
</div>
<p>When someone calls, should they ring certain phones or be greeted with a menu?</p>
<div class="input-group">
<input type="checkbox" asp-for="NewClient.PhoneMenu" class="form-control" />
<div class="input-group-prepend">
<span class="input-group-text">With textarea</span>
</div>
}
}
<textarea class="form-control" aria-label="With textarea" asp-for="NewClient.PhonesToRingOrMenuDescription"></textarea>
</div>
</div>
</div>
</div>

0 comments on commit a22143b

Please sign in to comment.