public async Task <Node> Put(int id, [FromBody] Node node) { var entry = _context.Nodes.Update(node); await _context.SaveChangesAsync(); return(entry.Entity); }
public async Task <IActionResult> OnPostAsync(string taxCode) { try { if (string.IsNullOrEmpty(taxCode)) { return(NotFound()); } var tbTaxCode = await NodeContext.App_tbTaxCodes.FindAsync(taxCode); NodeContext.App_tbTaxCodes.Remove(tbTaxCode); await NodeContext.SaveChangesAsync(); RouteValueDictionary route = new(); route.Add("taxTypeCode", tbTaxCode.TaxTypeCode); return(RedirectToPage("./Index", route)); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnPostAsync() { try { Cash_TransfersUnposted.CashAccountCode = await NodeContext.Org_tbAccounts.Where(t => t.CashAccountName == CashAccountName).Select(t => t.CashAccountCode).FirstOrDefaultAsync(); Cash_TransfersUnposted.CashCode = await NodeContext.Cash_tbCodes.Where(t => t.CashDescription == CashDescription).Select(t => t.CashCode).FirstOrDefaultAsync(); CashCodes cashCode = new(NodeContext, Cash_TransfersUnposted.CashCode); Cash_TransfersUnposted.TaxCode = cashCode.TaxCode; Cash_TransfersUnposted.UpdatedOn = DateTime.Now; Cash_TransfersUnposted.InsertedOn = DateTime.Now; if (!ModelState.IsValid || (Cash_TransfersUnposted.PaidInValue + Cash_TransfersUnposted.PaidOutValue == 0)) { return(Page()); } NodeContext.Cash_TransfersUnposted.Add(Cash_TransfersUnposted); await NodeContext.SaveChangesAsync(); return(RedirectToPage("./Index")); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnPostAsync(string accountCode, string cashCode) { try { if (accountCode == null || cashCode == null) { return(NotFound()); } var invoiceEntry = await NodeContext.Invoice_tbEntries.Where(t => t.AccountCode == accountCode && t.CashCode == cashCode).FirstAsync(); if (invoiceEntry != null) { NodeContext.Invoice_tbEntries.Remove(invoiceEntry); await NodeContext.SaveChangesAsync(); } return(RedirectToPage("./Index")); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnPostAsync() { try { Org_CashAccount.AccountTypeCode = await NodeContext.Org_tbAccountTypes.Where(t => t.AccountType == AccountType).Select(t => t.AccountTypeCode).FirstAsync(); Org_CashAccount.AccountCode = await NodeContext.Org_tbOrgs.Where(t => t.AccountName == OrganisationName).Select(t => t.AccountCode).FirstAsync(); if (!string.IsNullOrEmpty(CashDescription)) { Org_CashAccount.CashCode = await NodeContext.Cash_tbCodes.Where(t => t.CashDescription == CashDescription).Select(t => t.CashCode).FirstAsync(); } Org_CashAccount.CurrentBalance = Org_CashAccount.OpeningBalance; if (!ModelState.IsValid) { return(Page()); } NodeContext.Org_tbAccounts.Add(Org_CashAccount); await NodeContext.SaveChangesAsync(); RouteValueDictionary route = new(); route.Add("AccountType", AccountType); return(RedirectToPage("./Index", route)); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnPostAsync() { try { if (!ModelState.IsValid) { return(Page()); } NodeContext.Attach(Invoice_Type).State = EntityState.Modified; try { await NodeContext.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!await NodeContext.Invoice_tbTypes.AnyAsync(e => e.InvoiceTypeCode == Invoice_Type.InvoiceTypeCode)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnPostAsync(string categoryCode) { try { if (categoryCode == null) { return(NotFound()); } var totals = NodeContext.Cash_tbCategoryTotals.Where(t => t.ParentCode == categoryCode); foreach (var total in await totals.ToListAsync()) { NodeContext.Cash_tbCategoryTotals.Remove(total); } var tbCategory = await NodeContext.Cash_tbCategories.FindAsync(categoryCode); NodeContext.Cash_tbCategories.Remove(tbCategory); await NodeContext.SaveChangesAsync(); RouteValueDictionary route = new(); route.Add("cashTypeCode", tbCategory.CashTypeCode); return(RedirectToPage("./Index", route)); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnPostAsync(string id) { try { if (id == null) { return(NotFound()); } if (!ModelState.IsValid) { return(Page()); } NodeContext.Usr_tbUsers.Add(Usr_tbUser); await NodeContext.SaveChangesAsync(); var user = await UserManager.FindByIdAsync(id); var code = await UserManager.GenerateEmailConfirmationTokenAsync(user); await UserManager.ConfirmEmailAsync(user, code); return(RedirectToPage("./Index")); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnPostAsync(string paymentCode) { try { if (paymentCode == null) { return(NotFound()); } Cash_TransfersUnposted = await NodeContext.Cash_TransfersUnposted.FindAsync(paymentCode); if (Cash_TransfersUnposted != null) { NodeContext.Cash_TransfersUnposted.Remove(Cash_TransfersUnposted); await NodeContext.SaveChangesAsync(); } return(RedirectToPage("./Index")); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnPostAsync(string accountCode, string contactName) { try { if (accountCode == null || contactName == null) { return(NotFound()); } Org_tbContact tbContact = await NodeContext.Org_tbContacts.Where(c => c.AccountCode == accountCode && c.ContactName == contactName).FirstOrDefaultAsync();; if (tbContact != null) { NodeContext.Org_tbContacts.Remove(tbContact); await NodeContext.SaveChangesAsync(); } RouteValueDictionary route = new(); route.Add("accountCode", accountCode); return(RedirectToPage("./Index", route)); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnPostAsync() { try { Invoice_Entry.InvoiceTypeCode = await NodeContext.Invoice_tbTypes.Where(t => t.InvoiceType == InvoiceType).Select(t => t.InvoiceTypeCode).FirstAsync(); if (!ModelState.IsValid || (Invoice_Entry.TotalValue + Invoice_Entry.InvoiceValue == 0)) { return(Page()); } if (Invoice_Entry.TotalValue != 0 && Invoice_Entry.InvoiceValue != 0) { Invoice_Entry.InvoiceValue = 0; } Invoice_Entry.AccountCode = await NodeContext.Org_tbOrgs.Where(o => o.AccountName == OrganisationName).Select(o => o.AccountCode).FirstAsync(); Invoice_Entry.CashCode = await NodeContext.Cash_tbCodes.Where(c => c.CashDescription == CashDescription).Select(c => c.CashCode).FirstAsync(); Invoice_Entry.TaxCode = await NodeContext.App_tbTaxCodes.Where(c => c.TaxDescription == TaxDescription).Select(c => c.TaxCode).FirstAsync(); NodeContext.Invoice_tbEntries.Add(Invoice_Entry); await NodeContext.SaveChangesAsync(); return(RedirectToPage("./Index")); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnPostAsync() { try { if (!ModelState.IsValid) { return(Page()); } NodeContext.Org_tbAddresses.Add(Org_tbAddress); if (IsAdminAddress) { Org_tbOrg org = await NodeContext.Org_tbOrgs.FirstOrDefaultAsync(t => t.AccountCode == Org_tbAddress.AccountCode); org.AddressCode = Org_tbAddress.AddressCode; } await NodeContext.SaveChangesAsync(); RouteValueDictionary route = new(); route.Add("accountCode", Org_tbAddress.AccountCode); return(RedirectToPage("./Index", route)); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnPostAsync(string cashCode) { try { if (cashCode == null) { return(NotFound()); } var tbCashCode = await NodeContext.Cash_tbCodes.FindAsync(cashCode); NodeContext.Cash_tbCodes.Remove(tbCashCode); await NodeContext.SaveChangesAsync(); RouteValueDictionary route = new(); route.Add("Category", await NodeContext.Cash_tbCategories.Where(c => c.CategoryCode == tbCashCode.CategoryCode).Select(c => c.Category).FirstAsync()); return(RedirectToPage("./Index", route)); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnPostAsync(string cashAccountCode) { try { if (cashAccountCode == null) { return(NotFound()); } var cashAccount = await NodeContext.Org_tbAccounts.FindAsync(cashAccountCode); if (cashAccount != null) { NodeContext.Org_tbAccounts.Remove(cashAccount); await NodeContext.SaveChangesAsync(); } RouteValueDictionary route = new(); route.Add("AccountType", AccountType); return(RedirectToPage("./Index", route)); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnPostAsync(string accountCode) { try { if (accountCode == null) { return(NotFound()); } OrgAccount = await NodeContext.Org_Datasheet.FindAsync(accountCode); if (OrgAccount != null) { var tbOrg = await NodeContext.Org_tbOrgs.FindAsync(accountCode); NodeContext.Org_tbOrgs.Remove(tbOrg); await NodeContext.SaveChangesAsync(); } RouteValueDictionary route = new(); route.Add("OrganisationType", OrgAccount.OrganisationType); return(RedirectToPage("./Index", route)); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnPostAsync() { try { Cash_AssetsUnposted.UpdatedOn = DateTime.Now; Cash_AssetsUnposted.InsertedOn = DateTime.Now; if (!ModelState.IsValid || (Cash_AssetsUnposted.PaidInValue + Cash_AssetsUnposted.PaidOutValue == 0)) { return(Page()); } NodeContext.Cash_PaymentsUnposted.Add(Cash_AssetsUnposted); await NodeContext.SaveChangesAsync(); RouteValueDictionary route = new(); route.Add("CashAccountCode", Cash_AssetsUnposted.CashAccountCode); return(RedirectToPage("./Index", route)); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnPostAsync(string paymentCode) { try { if (paymentCode == null) { return(NotFound()); } Cash_PaymentsUnposted = await NodeContext.Cash_PaymentsUnposted.FindAsync(paymentCode); if (Cash_PaymentsUnposted != null) { NodeContext.Cash_PaymentsUnposted.Remove(Cash_PaymentsUnposted); await NodeContext.SaveChangesAsync(); } RouteValueDictionary route = new(); route.Add("CashAccountCode", Cash_PaymentsUnposted.CashAccountCode); return(RedirectToPage("./Index", route)); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnPostAsync() { try { if (!ModelState.IsValid) { return(Page()); } App_tbTaxCode.RoundingCode = await NodeContext.App_tbRoundings.Where(r => r.Rounding == Rounding).Select(r => r.RoundingCode).FirstAsync(); App_tbTaxCode.TaxTypeCode = await NodeContext.App_TaxCodeTypes.Where(t => t.TaxType == TaxType).Select(t => t.TaxTypeCode).FirstAsync(); NodeContext.App_tbTaxCodes.Add(App_tbTaxCode); await NodeContext.SaveChangesAsync(); RouteValueDictionary route = new(); route.Add("taxCode", App_tbTaxCode.TaxCode); if (!string.IsNullOrEmpty(ReturnUrl)) { return(RedirectToPage(ReturnUrl, route)); } else { return(RedirectToPage("./Index", route)); } } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } NodeContext.Attach(App_tbCalendar).State = EntityState.Modified; try { await NodeContext.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!App_tbCalendarExists(App_tbCalendar.CalendarCode)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync(string addressCode) { try { if (addressCode == null) { return(NotFound()); } Org_tbAddress tbAddress = await NodeContext.Org_tbAddresses.FindAsync(addressCode); if (tbAddress != null) { NodeContext.Org_tbAddresses.Remove(tbAddress); await NodeContext.SaveChangesAsync(); } RouteValueDictionary route = new(); route.Add("accountCode", tbAddress.AccountCode); return(RedirectToPage("./Index", route)); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnPostAsync() { try { if (!ModelState.IsValid) { return(Page()); } Cash_tbCategory.CashTypeCode = await NodeContext.Cash_tbTypes.Where(t => t.CashType == CashType).Select(t => t.CashTypeCode).FirstAsync(); Cash_tbCategory.CashModeCode = await NodeContext.Cash_tbModes.Where(m => m.CashMode == CashMode).Select(m => m.CashModeCode).FirstAsync(); NodeContext.Cash_tbCategories.Add(Cash_tbCategory); await NodeContext.SaveChangesAsync(); if (!string.IsNullOrEmpty(ReturnUrl)) { return(LocalRedirect($"{ReturnUrl}?categorycode={Cash_tbCategory.CategoryCode}")); } else { RouteValueDictionary route = new(); route.Add("cashTypeCode", Cash_tbCategory.CashTypeCode); return(RedirectToPage("./Index", route)); } } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnPostAsync(string paymentCode) { try { if (paymentCode == null) { return(NotFound()); } CashAccounts cashAccounts = new(NodeContext); if (await cashAccounts.PostAsset(paymentCode)) { await NodeContext.SaveChangesAsync(); string cashAccountCode = await NodeContext.Cash_tbPayments.Where(t => t.PaymentCode == paymentCode).Select(t => t.CashAccountCode).FirstAsync(); RouteValueDictionary route = new(); route.Add("CashAccountCode", cashAccountCode); return(RedirectToPage("./Index", route)); } else { throw new Exception("Post failed! Consult logs"); } } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnPostAsync(string invoiceNumber) { try { if (invoiceNumber == null) { return(NotFound()); } var invoice = await NodeContext.Invoice_tbInvoices.Where(t => t.InvoiceNumber == invoiceNumber).FirstAsync(); if (invoice != null) { invoice.InvoiceStatusCode = (short)NodeEnum.InvoiceStatus.Pending; NodeContext.Attach(invoice).State = EntityState.Modified; try { await NodeContext.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!await NodeContext.Invoice_tbInvoices.AnyAsync(e => e.InvoiceNumber == invoice.InvoiceNumber)) { return(NotFound()); } else { throw; } } Invoices invoices = new(NodeContext); if (await invoices.CancelPending(invoice.UserId)) { Orgs orgs = new(NodeContext, invoice.AccountCode); await orgs.Rebuild(); return(RedirectToPage("./Index")); } else { throw new Exception($"Invoice {invoiceNumber} failed cancellation request."); } } else { return(RedirectToPage("./Index")); } } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } NodeContext.App_tbCalendars.Add(App_tbCalendar); await NodeContext.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { try { if (!ModelState.IsValid) { return(Page()); } Profile profile = new(NodeContext); Org_tbAddress.UpdatedBy = await profile.UserName(UserManager.GetUserId(User)); NodeContext.Attach(Org_tbAddress).State = EntityState.Modified; if (IsAdminAddress) { Org_tbOrg org = await NodeContext.Org_tbOrgs.FirstOrDefaultAsync(t => t.AccountCode == Org_tbAddress.AccountCode); if (org.AddressCode != Org_tbAddress.AddressCode) { org.AddressCode = Org_tbAddress.AddressCode; NodeContext.Attach(org).State = EntityState.Modified; } } try { await NodeContext.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!await NodeContext.Org_tbAddresses.AnyAsync(e => e.AddressCode == Org_tbAddress.AddressCode)) { return(NotFound()); } else { throw; } } RouteValueDictionary route = new(); route.Add("accountCode", Org_tbAddress.AccountCode); return(RedirectToPage("./Index", route)); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnPostAsync() { try { if (!ModelState.IsValid) { return(Page()); } Profile profile = new(NodeContext); Cash_Payment.UpdatedBy = await profile.UserName(UserManager.GetUserId(User)); if (!string.IsNullOrEmpty(Cash_Payment.CashCode)) { Cash_Payment.CashCode = await NodeContext.Cash_tbCodes.Where(c => c.CashDescription == CashDescription).Select(c => c.CashCode).FirstAsync(); Cash_Payment.TaxCode = await NodeContext.App_tbTaxCodes.Where(c => c.TaxDescription == TaxDescription).Select(c => c.TaxCode).FirstAsync(); } NodeContext.Attach(Cash_Payment).State = EntityState.Modified; try { await NodeContext.SaveChangesAsync(); Orgs org = new(NodeContext, Cash_Payment.AccountCode); await org.Rebuild(); } catch (DbUpdateConcurrencyException) { if (!await NodeContext.Cash_tbPayments.AnyAsync(e => e.PaymentCode == Cash_Payment.PaymentCode)) { return(NotFound()); } else { throw; } } RouteValueDictionary route = new(); route.Add("PaymentCode", Cash_Payment.PaymentCode); return(RedirectToPage("./Index", route)); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnPostAsync() { try { if (!ModelState.IsValid) { return(Page()); } Cash_tbCategory.IsEnabled = (short)(IsEnabled ? 1 : 0); Cash_tbCategory.CashTypeCode = await NodeContext.Cash_tbTypes.Where(t => t.CashType == CashType).Select(t => t.CashTypeCode).FirstAsync(); Cash_tbCategory.CashModeCode = await NodeContext.Cash_tbModes.Where(m => m.CashMode == CashMode).Select(m => m.CashModeCode).FirstAsync(); Profile profile = new(NodeContext); Cash_tbCategory.UpdatedBy = await profile.UserName(UserManager.GetUserId(User)); Cash_tbCategory.UpdatedOn = DateTime.Now; NodeContext.Attach(Cash_tbCategory).State = EntityState.Modified; try { await NodeContext.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!await NodeContext.Cash_tbCategories.AnyAsync(e => e.CategoryCode == Cash_tbCategory.CategoryCode)) { return(NotFound()); } else { throw; } } RouteValueDictionary route = new(); route.Add("cashTypeCode", Cash_tbCategory.CashTypeCode); return(RedirectToPage("./Index", route)); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnPostAsync(string id) { if (id == null) { return(NotFound()); } App_tbCalendar = await NodeContext.App_tbCalendars.FindAsync(id); if (App_tbCalendar != null) { NodeContext.App_tbCalendars.Remove(App_tbCalendar); await NodeContext.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public async Task <IActionResult> OnPostAsync() { try { if (!ModelState.IsValid) { return(Page()); } if (Invoice_Item.TotalValue != 0 && Invoice_Item.InvoiceValue != 0) { Invoice_Item.InvoiceValue = 0; } Invoice_Item.CashCode = await NodeContext.Cash_tbCodes.Where(c => c.CashDescription == CashDescription).Select(c => c.CashCode).FirstAsync(); Invoice_Item.TaxCode = await NodeContext.App_tbTaxCodes.Where(c => c.TaxDescription == TaxDescription).Select(c => c.TaxCode).FirstAsync(); NodeContext.Invoice_tbItems.Add(Invoice_Item); await NodeContext.SaveChangesAsync(); Invoices invoices = new(NodeContext, Invoice_Item.InvoiceNumber); await invoices.Accept(); var invoiceHeader = await NodeContext.Invoice_tbInvoices.Where(i => i.InvoiceNumber == Invoice_Item.InvoiceNumber).FirstAsync(); FinancialPeriods periods = new(NodeContext); if (invoiceHeader.InvoicedOn < periods.ActiveStartOn) { await periods.Generate(); } Orgs orgs = new(NodeContext, invoiceHeader.AccountCode); await orgs.Rebuild(); RouteValueDictionary route = new(); route.Add("InvoiceNumber", Invoice_Item.InvoiceNumber); return(RedirectToPage("./Edit", route)); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }
public async Task <IActionResult> OnPostAsync() { try { if (!ModelState.IsValid) { return(Page()); } Profile profile = new(NodeContext); Org_tbOrg.UpdatedBy = await profile.UserName(UserManager.GetUserId(User)); Org_tbOrg.OrganisationStatusCode = await NodeContext.Org_tbStatuses.Where(t => t.OrganisationStatus == OrganisationStatus).Select(t => t.OrganisationStatusCode).FirstAsync(); Org_tbOrg.OrganisationTypeCode = await NodeContext.Org_tbTypes.Where(t => t.OrganisationType == OrganisationType).Select(t => t.OrganisationTypeCode).FirstAsync(); Org_tbOrg.TaxCode = await NodeContext.App_tbTaxCodes.Where(t => t.TaxDescription == TaxDescription).Select(t => t.TaxCode).FirstAsync(); NodeContext.Attach(Org_tbOrg).State = EntityState.Modified; try { await NodeContext.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!await NodeContext.Org_tbOrgs.AnyAsync(e => e.AccountCode == Org_tbOrg.AccountCode)) { return(NotFound()); } else { throw; } } RouteValueDictionary route = new(); route.Add("accountCode", Org_tbOrg.AccountCode); return(RedirectToPage("./Index", route)); } catch (Exception e) { NodeContext.ErrorLog(e); throw; } }