This commit is contained in:
2018-07-19 20:34:58 +00:00
parent 10ded2681f
commit 17671874ce
4 changed files with 91 additions and 43 deletions

View File

@@ -90,7 +90,7 @@ namespace rockfishCore.Controllers
throw;
}
}
updateCustomerActive(purchase.CustomerId);
// updateCustomerActive(purchase.CustomerId);
ParseOrderAndUpdateEmail(purchase);
return NoContent();
}
@@ -107,7 +107,7 @@ namespace rockfishCore.Controllers
_context.Purchase.Add(purchase);
await _context.SaveChangesAsync();
updateCustomerActive(purchase.CustomerId);
// updateCustomerActive(purchase.CustomerId);
ParseOrderAndUpdateEmail(purchase);
return CreatedAtAction("GetPurchase", new { id = purchase.Id }, purchase);
@@ -132,7 +132,9 @@ namespace rockfishCore.Controllers
_context.Purchase.Remove(purchase);
await _context.SaveChangesAsync();
updateCustomerActive(customerId);
//removed, now have the concept of lapsed so active should be in manual control
//
// updateCustomerActive(customerId);
return Ok(purchase);
}
@@ -141,24 +143,24 @@ namespace rockfishCore.Controllers
return _context.Purchase.Any(e => e.Id == id);
}
//check if customer has any active subs and flag accordingly
private void updateCustomerActive(long customerId)
{
var cust = _context.Customer.First(m => m.Id == customerId);
bool active = hasActiveSubs(customerId);
if (cust.Active != active)
{
cust.Active = active;
_context.Customer.Update(cust);
_context.SaveChanges();
}
}
// //check if customer has any active subs and flag accordingly
// private void updateCustomerActive(long customerId)
// {
// var cust = _context.Customer.First(m => m.Id == customerId);
// bool active = hasActiveSubs(customerId);
// if (cust.Active != active)
// {
// cust.Active = active;
// _context.Customer.Update(cust);
// _context.SaveChanges();
// }
// }
//check if a customer has active subscriptions
private bool hasActiveSubs(long customerId)
{
return _context.Purchase.Where(m => m.CustomerId == customerId && m.CancelDate == null).Count() > 0;
}
// //check if a customer has active subscriptions
// private bool hasActiveSubs(long customerId)
// {
// return _context.Purchase.Where(m => m.CustomerId == customerId && m.CancelDate == null).Count() > 0;
// }

View File

@@ -23,10 +23,31 @@ app.customers = (function() {
//
generateCard = function(obj) {
var editUrl = "#!/customerEdit/" + obj.id;
var cardClass = obj.active
? "border-primary text-primary"
: "border-secondary text-secondary";
var urlClass = obj.active ? "" : "text-secondary";
var cardClass = "";
var urlClass = "";
//LAPSED
if (obj.active && obj.lapsed) {
cardClass = "border-warning text-warning";
urlClass = "text-warning";
}
//ACTIVE
if (obj.active && !obj.lapsed) {
cardClass = "border-primary text-primary";
}
//INACTIVE
if (!obj.active) {
cardClass = "border-primary text-primary";
urlClass = "text-secondary";
}
// var cardClass = obj.active
// ? "border-primary text-primary"
// : "border-secondary text-secondary";
// var urlClass = obj.active ? "" : "text-secondary";
return (
'<div class="card ' +
@@ -146,33 +167,40 @@ app.customers = (function() {
if (res.error) {
$.gevent.publish("app-show-error", res.msg);
} else {
var $appList = $("#rf-list");
var $appListActive = $("#rf-list-active");
var $appListLapsed = $("#rf-list-lapsed");
var $appListInActive = $("#rf-list-inactive");
var activeCount = 0;
var inactiveCount = 0;
var lapsedCount = 0;
$.each(res, function(i, obj) {
if (obj.active) {
activeCount++;
if (obj.lapsed) {
lapsedCount++;
$appListLapsed.append(generateCard(obj));
$("#btnMore" + obj.id).bind("click", obj.id, onShowMore);
} else {
activeCount++;
$appListActive.append(generateCard(obj));
$("#btnMore" + obj.id).bind("click", obj.id, onShowMore);
}
} else {
inactiveCount++;
$appListInActive.append(generateCard(obj));
$("#btnMore" + obj.id).bind("click", obj.id, onShowMore);
}
$appList.append(generateCard(obj));
$("#btnMore" + obj.id).bind("click", obj.id, onShowMore);
});
//Show the count of customers active and inactive
//Show the count of customers by status
$("#rf-list-count")
.empty()
.append(
res.length +
" items (" +
activeCount +
" active, " +
inactiveCount +
" inactive)"
);
.append(res.length + " items ");
$("#rf-active-count-badge").text(activeCount);
$("#rf-lapsed-count-badge").text(lapsedCount);
$("#rf-inactive-count-badge").text(inactiveCount);
}
});
//=========/customers==============

View File

@@ -1,4 +1,22 @@
<div>
<div id="rf-list-count"/>
<div id="rf-list" class="rf-list"/>
<div>
<div id="rf-list-count" />
<h4 class="mt-5 text-primary">Active
<span id="rf-active-count-badge" class="badge badge-primary"></span>
</h4>
<div id="rf-list-active" class="rf-list" />
<h4 class="mt-5 text-warning">Lapsed
<span id="rf-lapsed-count-badge" class="badge badge-warning"></span>
</h4>
<div id="rf-list-lapsed" class="rf-list" />
<h4 class="mt-5 text-secondary">
Inactive
<span id="rf-inactive-count-badge" class="badge badge-secondary"></span>
</h4>
<a class="btn btn-primary" data-toggle="collapse" href="#rf-list-inactive" role="button" aria-expanded="false" aria-controls="rf-list-inactive">+</a>
<div id="rf-list-inactive" class="collapse rf-list" />
</div>

File diff suppressed because one or more lines are too long