zadnjih 100 artiklov
gumb nazaj da vrne na projekt
This commit is contained in:
@@ -58,36 +58,50 @@ namespace EveryThing.Pages.Invoices
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Invoice = await _context.Invoices
|
||||
.Include(f => f.Company).FirstOrDefaultAsync(m => m.IdInvoice == id);
|
||||
var result = await LoadInvoiceData(id);
|
||||
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
if (Invoice == null)
|
||||
if (!result)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
private async Task<bool> LoadInvoiceData(int? id)
|
||||
{
|
||||
Invoice = await _context.Invoices
|
||||
.Include(f => f.Company).FirstOrDefaultAsync(m => m.IdInvoice == id);
|
||||
|
||||
|
||||
if (Invoice == null) return false;
|
||||
|
||||
InvoiceItems = await _context.InvoiceItems
|
||||
.Include(f => f.Item)
|
||||
.Where(m => m.IdInvoiceFk == id)
|
||||
.ToListAsync();
|
||||
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
ViewData["Type"] = (int)Invoice.Type;
|
||||
ViewData["IdPartnerFk"] = new SelectList(_context.CodeTablePartners.Where(x => x.IdCompanyFk == user.IdCompanyFk && x.Active), "IdPartner", "Title");
|
||||
|
||||
ViewData["States"] = new SelectList(Enum.GetValues(typeof(Models.Invoice.Invoice.InvoiceState))
|
||||
.Cast<Models.Invoice.Invoice.InvoiceState>()
|
||||
.Where(x => GetAttribute<Models.Invoice.Invoice.InvoiceStateAttribute>(x).AllowedTypes.Split(',').Contains(((int)Invoice.Type).ToString()))
|
||||
.Select(x => new { Name = GetAttribute<DisplayAttribute>(x).Name, Value = x.ToString()})
|
||||
.Select(x => new { Name = GetAttribute<DisplayAttribute>(x).Name, Value = x.ToString() })
|
||||
.ToList(), "Value", "Name");
|
||||
|
||||
if (!string.IsNullOrEmpty(Request.Headers["Referer"]))
|
||||
if (!string.IsNullOrEmpty(Reffer))
|
||||
{
|
||||
ViewData["Reffer"] = Reffer;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(Request.Headers["Referer"]))
|
||||
{
|
||||
ViewData["Reffer"] = Reffer = Request.Headers["Referer"].ToString();
|
||||
}
|
||||
|
||||
return Page();
|
||||
return true;
|
||||
}
|
||||
|
||||
public static TAttribute GetAttribute<TAttribute>(Enum value)
|
||||
@@ -144,7 +158,9 @@ namespace EveryThing.Pages.Invoices
|
||||
}
|
||||
}
|
||||
|
||||
return RedirectToPage("./Edit", new { id = Invoice.IdInvoice});
|
||||
await LoadInvoiceData(Invoice.IdInvoice);
|
||||
|
||||
return Page();// RedirectToPage("./Edit", new { id = Invoice.IdInvoice});
|
||||
|
||||
|
||||
if (Reffer != null)
|
||||
|
||||
Reference in New Issue
Block a user