This commit is contained in:
@@ -17,11 +17,11 @@ namespace rockfishCore.Controllers
|
|||||||
[Authorize]
|
[Authorize]
|
||||||
public class CustomerController : Controller
|
public class CustomerController : Controller
|
||||||
{
|
{
|
||||||
private readonly rockfishContext _context;
|
private readonly rockfishContext ct;
|
||||||
|
|
||||||
public CustomerController(rockfishContext context)
|
public CustomerController(rockfishContext context)
|
||||||
{
|
{
|
||||||
_context = context;
|
ct = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get api/customer/list
|
//Get api/customer/list
|
||||||
@@ -29,7 +29,7 @@ namespace rockfishCore.Controllers
|
|||||||
public IEnumerable<dtoCustomerListItem> GetList()
|
public IEnumerable<dtoCustomerListItem> GetList()
|
||||||
{
|
{
|
||||||
|
|
||||||
var res = from c in _context.Customer.OrderBy(c => c.Name)
|
var res = from c in ct.Customer.OrderBy(c => c.Name)
|
||||||
select new dtoCustomerListItem
|
select new dtoCustomerListItem
|
||||||
{
|
{
|
||||||
lapsed = false,
|
lapsed = false,
|
||||||
@@ -88,12 +88,15 @@ namespace rockfishCore.Controllers
|
|||||||
{
|
{
|
||||||
long EpochNow = DateUtil.NowAsEpoch();
|
long EpochNow = DateUtil.NowAsEpoch();
|
||||||
|
|
||||||
var count = _context.Purchase
|
var count = ct.Purchase
|
||||||
.Where(c => c.CustomerId.Equals(customerId))
|
.Where(c => c.CustomerId.Equals(customerId))
|
||||||
.Where(c => c.CancelDate == null || c.CancelDate > EpochNow)
|
.Where(c => c.CancelDate == null || c.CancelDate > EpochNow)
|
||||||
.Where(c => c.ExpireDate != null && c.ExpireDate > EpochNow)
|
.Where(c => c.ExpireDate != null && c.ExpireDate > EpochNow)
|
||||||
.Count();
|
.Count();
|
||||||
|
|
||||||
|
//handle raven keys here
|
||||||
|
// var ravActiveMaintenanceCount=ct.License.Where(z=>z.CustomerId==customerId && z.)
|
||||||
|
|
||||||
return count < 1;
|
return count < 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -103,7 +106,7 @@ namespace rockfishCore.Controllers
|
|||||||
public IEnumerable<dtoNameIdItem> GetSiteList([FromRoute] long id)
|
public IEnumerable<dtoNameIdItem> GetSiteList([FromRoute] long id)
|
||||||
{
|
{
|
||||||
|
|
||||||
var res = from c in _context.Site
|
var res = from c in ct.Site
|
||||||
.Where(c => c.CustomerId.Equals(id)).OrderBy(c => c.Name)
|
.Where(c => c.CustomerId.Equals(id)).OrderBy(c => c.Name)
|
||||||
select new dtoNameIdItem
|
select new dtoNameIdItem
|
||||||
{
|
{
|
||||||
@@ -121,7 +124,7 @@ namespace rockfishCore.Controllers
|
|||||||
|
|
||||||
long EpochNow = DateUtil.NowAsEpoch();
|
long EpochNow = DateUtil.NowAsEpoch();
|
||||||
|
|
||||||
var res = from c in _context.Site
|
var res = from c in ct.Site
|
||||||
.Where(c => c.CustomerId.Equals(id)).OrderBy(c => c.Name)
|
.Where(c => c.CustomerId.Equals(id)).OrderBy(c => c.Name)
|
||||||
select new dtoNameIdChildrenItem
|
select new dtoNameIdChildrenItem
|
||||||
{
|
{
|
||||||
@@ -134,7 +137,7 @@ namespace rockfishCore.Controllers
|
|||||||
|
|
||||||
foreach (dtoNameIdChildrenItem child in resList)
|
foreach (dtoNameIdChildrenItem child in resList)
|
||||||
{
|
{
|
||||||
var subs = from c in _context.Purchase
|
var subs = from c in ct.Purchase
|
||||||
.Where(c => c.SiteId.Equals(child.id))
|
.Where(c => c.SiteId.Equals(child.id))
|
||||||
.Where(c => c.CancelDate == null || c.CancelDate > EpochNow)
|
.Where(c => c.CancelDate == null || c.CancelDate > EpochNow)
|
||||||
.OrderByDescending(c => c.PurchaseDate)
|
.OrderByDescending(c => c.PurchaseDate)
|
||||||
@@ -160,7 +163,7 @@ namespace rockfishCore.Controllers
|
|||||||
public IEnumerable<Site> GetSites([FromRoute] long id)
|
public IEnumerable<Site> GetSites([FromRoute] long id)
|
||||||
{
|
{
|
||||||
//from https://docs.microsoft.com/en-us/ef/core/querying/basic
|
//from https://docs.microsoft.com/en-us/ef/core/querying/basic
|
||||||
var sites = _context.Site
|
var sites = ct.Site
|
||||||
.Where(b => b.CustomerId.Equals(id))
|
.Where(b => b.CustomerId.Equals(id))
|
||||||
.OrderByDescending(b => b.Id)
|
.OrderByDescending(b => b.Id)
|
||||||
.ToList();
|
.ToList();
|
||||||
@@ -206,7 +209,7 @@ namespace rockfishCore.Controllers
|
|||||||
//on this client url
|
//on this client url
|
||||||
//http://localhost:5000/default.htm#!/customerSites/85
|
//http://localhost:5000/default.htm#!/customerSites/85
|
||||||
|
|
||||||
var ret = await _context.Customer
|
var ret = await ct.Customer
|
||||||
.Select(r => new { r.Id, r.Name })
|
.Select(r => new { r.Id, r.Name })
|
||||||
.Where(r => r.Id == id)
|
.Where(r => r.Id == id)
|
||||||
.FirstAsync();
|
.FirstAsync();
|
||||||
@@ -226,7 +229,7 @@ namespace rockfishCore.Controllers
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IEnumerable<Customer> GetCustomer()
|
public IEnumerable<Customer> GetCustomer()
|
||||||
{
|
{
|
||||||
return _context.Customer;
|
return ct.Customer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -241,7 +244,7 @@ namespace rockfishCore.Controllers
|
|||||||
return BadRequest(ModelState);
|
return BadRequest(ModelState);
|
||||||
}
|
}
|
||||||
|
|
||||||
var customer = await _context.Customer.SingleOrDefaultAsync(m => m.Id == id);
|
var customer = await ct.Customer.SingleOrDefaultAsync(m => m.Id == id);
|
||||||
|
|
||||||
if (customer == null)
|
if (customer == null)
|
||||||
{
|
{
|
||||||
@@ -265,11 +268,11 @@ namespace rockfishCore.Controllers
|
|||||||
return BadRequest();
|
return BadRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
_context.Entry(customer).State = EntityState.Modified;
|
ct.Entry(customer).State = EntityState.Modified;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _context.SaveChangesAsync();
|
await ct.SaveChangesAsync();
|
||||||
}
|
}
|
||||||
catch (DbUpdateConcurrencyException)
|
catch (DbUpdateConcurrencyException)
|
||||||
{
|
{
|
||||||
@@ -296,8 +299,8 @@ namespace rockfishCore.Controllers
|
|||||||
return BadRequest(ModelState);
|
return BadRequest(ModelState);
|
||||||
}
|
}
|
||||||
|
|
||||||
_context.Customer.Add(customer);
|
ct.Customer.Add(customer);
|
||||||
await _context.SaveChangesAsync();
|
await ct.SaveChangesAsync();
|
||||||
|
|
||||||
return CreatedAtAction("GetCustomer", new { id = customer.Id }, customer);
|
return CreatedAtAction("GetCustomer", new { id = customer.Id }, customer);
|
||||||
}
|
}
|
||||||
@@ -311,21 +314,21 @@ namespace rockfishCore.Controllers
|
|||||||
return BadRequest(ModelState);
|
return BadRequest(ModelState);
|
||||||
}
|
}
|
||||||
|
|
||||||
var customer = await _context.Customer.SingleOrDefaultAsync(m => m.Id == id);
|
var customer = await ct.Customer.SingleOrDefaultAsync(m => m.Id == id);
|
||||||
if (customer == null)
|
if (customer == null)
|
||||||
{
|
{
|
||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
_context.Customer.Remove(customer);
|
ct.Customer.Remove(customer);
|
||||||
await _context.SaveChangesAsync();
|
await ct.SaveChangesAsync();
|
||||||
|
|
||||||
return Ok(customer);
|
return Ok(customer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CustomerExists(long id)
|
private bool CustomerExists(long id)
|
||||||
{
|
{
|
||||||
return _context.Customer.Any(e => e.Id == id);
|
return ct.Customer.Any(e => e.Id == id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -136,7 +136,7 @@ namespace rockfishCore.Controllers
|
|||||||
|
|
||||||
//Key generated, record saved successfully
|
//Key generated, record saved successfully
|
||||||
//inform customer and return no content
|
//inform customer and return no content
|
||||||
var body = $"Thank you for your purchase!\nYour AyaNova license key is ready to be installed.\nAyaNova will fetch it automatically within 24 hours or you can force it to fetch immediately from the License page in AyaNova now.\n---\n{l}";
|
var body = $"Thank you for your purchase!\nYour AyaNova license key is ready to be installed.\nAyaNova will fetch it automatically within 24 hours or you can force it to fetch immediately from the License page in AyaNova now.\n---\n{l.ToString()}";
|
||||||
//send license email
|
//send license email
|
||||||
#if (DEBUG)
|
#if (DEBUG)
|
||||||
RfMail.SendMessage("support@ayanova.com", "cardjohn@ayanova.com", "AyaNova license key", body, false);
|
RfMail.SendMessage("support@ayanova.com", "cardjohn@ayanova.com", "AyaNova license key", body, false);
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ namespace rockfishCore.Models
|
|||||||
public long? DtFetched { get; set; }
|
public long? DtFetched { get; set; }
|
||||||
public bool Fetched { get; set; }
|
public bool Fetched { get; set; }
|
||||||
public Guid DbId { get; set; }
|
public Guid DbId { get; set; }
|
||||||
|
public long DtLicenseExpiration { get; set; }
|
||||||
|
public long DtMaintenanceExpiration { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -374,6 +374,8 @@ namespace rockfishCore.Util
|
|||||||
exec("update site set legacyv7 = 1");
|
exec("update site set legacyv7 = 1");
|
||||||
exec("alter table license add dbid text default 'v7_no_dbid' NOT NULL");
|
exec("alter table license add dbid text default 'v7_no_dbid' NOT NULL");
|
||||||
exec("alter table license add siteid integer");
|
exec("alter table license add siteid integer");
|
||||||
|
exec("alter table license add dtLicenseExpiration integer");
|
||||||
|
exec("alter table license add dtMaintenanceExpiration integer");
|
||||||
exec("alter table purchase add quantity integer default 1 not null");
|
exec("alter table purchase add quantity integer default 1 not null");
|
||||||
exec("insert into product (name, productCode, price, renewPrice) values ('TEST RAVEN schedulable resource 1 year subscription license','testfeatscheduser',15900, 5565);");
|
exec("insert into product (name, productCode, price, renewPrice) values ('TEST RAVEN schedulable resource 1 year subscription license','testfeatscheduser',15900, 5565);");
|
||||||
exec("insert into product (name, productCode, price, renewPrice) values ('TEST RAVEN Accounting 1 year subscription license','testfeatacct',15000, 5250);");
|
exec("insert into product (name, productCode, price, renewPrice) values ('TEST RAVEN Accounting 1 year subscription license','testfeatacct',15000, 5250);");
|
||||||
|
|||||||
Reference in New Issue
Block a user