This commit is contained in:
@@ -90,7 +90,7 @@ namespace rockfishCore.Controllers
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateCustomerActive(purchase.CustomerId);
|
// updateCustomerActive(purchase.CustomerId);
|
||||||
ParseOrderAndUpdateEmail(purchase);
|
ParseOrderAndUpdateEmail(purchase);
|
||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
@@ -107,7 +107,7 @@ namespace rockfishCore.Controllers
|
|||||||
_context.Purchase.Add(purchase);
|
_context.Purchase.Add(purchase);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
updateCustomerActive(purchase.CustomerId);
|
// updateCustomerActive(purchase.CustomerId);
|
||||||
ParseOrderAndUpdateEmail(purchase);
|
ParseOrderAndUpdateEmail(purchase);
|
||||||
|
|
||||||
return CreatedAtAction("GetPurchase", new { id = purchase.Id }, purchase);
|
return CreatedAtAction("GetPurchase", new { id = purchase.Id }, purchase);
|
||||||
@@ -132,7 +132,9 @@ namespace rockfishCore.Controllers
|
|||||||
_context.Purchase.Remove(purchase);
|
_context.Purchase.Remove(purchase);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
updateCustomerActive(customerId);
|
//removed, now have the concept of lapsed so active should be in manual control
|
||||||
|
//
|
||||||
|
// updateCustomerActive(customerId);
|
||||||
return Ok(purchase);
|
return Ok(purchase);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,24 +143,24 @@ namespace rockfishCore.Controllers
|
|||||||
return _context.Purchase.Any(e => e.Id == id);
|
return _context.Purchase.Any(e => e.Id == id);
|
||||||
}
|
}
|
||||||
|
|
||||||
//check if customer has any active subs and flag accordingly
|
// //check if customer has any active subs and flag accordingly
|
||||||
private void updateCustomerActive(long customerId)
|
// private void updateCustomerActive(long customerId)
|
||||||
{
|
// {
|
||||||
var cust = _context.Customer.First(m => m.Id == customerId);
|
// var cust = _context.Customer.First(m => m.Id == customerId);
|
||||||
bool active = hasActiveSubs(customerId);
|
// bool active = hasActiveSubs(customerId);
|
||||||
if (cust.Active != active)
|
// if (cust.Active != active)
|
||||||
{
|
// {
|
||||||
cust.Active = active;
|
// cust.Active = active;
|
||||||
_context.Customer.Update(cust);
|
// _context.Customer.Update(cust);
|
||||||
_context.SaveChanges();
|
// _context.SaveChanges();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
//check if a customer has active subscriptions
|
// //check if a customer has active subscriptions
|
||||||
private bool hasActiveSubs(long customerId)
|
// private bool hasActiveSubs(long customerId)
|
||||||
{
|
// {
|
||||||
return _context.Purchase.Where(m => m.CustomerId == customerId && m.CancelDate == null).Count() > 0;
|
// return _context.Purchase.Where(m => m.CustomerId == customerId && m.CancelDate == null).Count() > 0;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,10 +23,31 @@ app.customers = (function() {
|
|||||||
//
|
//
|
||||||
generateCard = function(obj) {
|
generateCard = function(obj) {
|
||||||
var editUrl = "#!/customerEdit/" + obj.id;
|
var editUrl = "#!/customerEdit/" + obj.id;
|
||||||
var cardClass = obj.active
|
|
||||||
? "border-primary text-primary"
|
var cardClass = "";
|
||||||
: "border-secondary text-secondary";
|
var urlClass = "";
|
||||||
var urlClass = obj.active ? "" : "text-secondary";
|
|
||||||
|
//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 (
|
return (
|
||||||
'<div class="card ' +
|
'<div class="card ' +
|
||||||
@@ -146,33 +167,40 @@ app.customers = (function() {
|
|||||||
if (res.error) {
|
if (res.error) {
|
||||||
$.gevent.publish("app-show-error", res.msg);
|
$.gevent.publish("app-show-error", res.msg);
|
||||||
} else {
|
} else {
|
||||||
var $appList = $("#rf-list");
|
var $appListActive = $("#rf-list-active");
|
||||||
|
var $appListLapsed = $("#rf-list-lapsed");
|
||||||
|
var $appListInActive = $("#rf-list-inactive");
|
||||||
|
|
||||||
var activeCount = 0;
|
var activeCount = 0;
|
||||||
var inactiveCount = 0;
|
var inactiveCount = 0;
|
||||||
|
var lapsedCount = 0;
|
||||||
|
|
||||||
$.each(res, function(i, obj) {
|
$.each(res, function(i, obj) {
|
||||||
if (obj.active) {
|
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 {
|
} else {
|
||||||
inactiveCount++;
|
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")
|
$("#rf-list-count")
|
||||||
.empty()
|
.empty()
|
||||||
.append(
|
.append(res.length + " items ");
|
||||||
res.length +
|
|
||||||
" items (" +
|
$("#rf-active-count-badge").text(activeCount);
|
||||||
activeCount +
|
$("#rf-lapsed-count-badge").text(lapsedCount);
|
||||||
" active, " +
|
$("#rf-inactive-count-badge").text(inactiveCount);
|
||||||
inactiveCount +
|
|
||||||
" inactive)"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//=========/customers==============
|
//=========/customers==============
|
||||||
|
|||||||
@@ -1,4 +1,22 @@
|
|||||||
<div>
|
<div>
|
||||||
<div id="rf-list-count"/>
|
<div id="rf-list-count" />
|
||||||
<div id="rf-list" class="rf-list"/>
|
<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>
|
</div>
|
||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user