Spaces:
Sleeping
Sleeping
Download InvoicesController.cs from Ahmedtiger7/quick: direct link, hf CLI and curl.
- Browser
- Download file 1.38 kB
-
https://huggingface.co/spaces/Ahmedtiger7/quick/resolve/main/InvoicesController.cs
- Command line
-
hf download hf://spaces/Ahmedtiger7/quick/InvoicesController.cs
-
curl -L -o InvoicesController.cs https://huggingface.co/spaces/Ahmedtiger7/quick/resolve/main/InvoicesController.cs
1.38 kB
| using Microsoft.AspNetCore.Mvc; | |
| using Microsoft.EntityFrameworkCore; | |
| using QuickInvoiceSaaS.Data; | |
| using QuickInvoiceSaaS.Models; | |
| namespace QuickInvoiceSaaS.Controllers | |
| { | |
| [] | |
| [] | |
| public class InvoicesController : ControllerBase | |
| { | |
| private readonly ApplicationDbContext _context; | |
| public InvoicesController(ApplicationDbContext context) | |
| { | |
| _context = context; | |
| } | |
| // 1. دالة جلب الفواتير (ستجلب تلقائياً فواتير الشركة الحالية فقط بفضل الـ Filter) | |
| [] | |
| public async Task<IActionResult> GetAll() | |
| { | |
| var invoices = await _context.Invoices.Include(i => i.Items).ToListAsync(); | |
| return Ok(invoices); | |
| } | |
| // 2. دالة إنشاء فاتورة جديدة (سيتم حقن الـ TenantId تلقائياً قبل الحفظ) | |
| [] | |
| public async Task<IActionResult> Create([FromBody] Invoice invoice) | |
| { | |
| if (!ModelState.IsValid) return BadRequest(ModelState); | |
| _context.Invoices.Add(invoice); | |
| await _context.SaveChangesAsync(); | |
| return Ok(new { message = "تم إنشاء الفاتورة بنجاح!", invoiceId = invoice.Id }); | |
| } | |
| } | |
| } |