ogled ponudb
This commit is contained in:
@@ -1,31 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using DocumentFormat.OpenXml.InkML;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using EveryThing.Data;
|
||||
using EveryThing.Models;
|
||||
using EveryThing.Models.CodeTable;
|
||||
using EveryThing.Models.Invoice;
|
||||
using EveryThing.Models.Project;
|
||||
using EveryThing.Models.Vehicle;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using EveryThing.Data;
|
||||
using EveryThing.Models;
|
||||
using EveryThing.Models.Project;
|
||||
using System.Text.Json;
|
||||
using EveryThing.Models.CodeTable;
|
||||
using DocumentFormat.OpenXml.InkML;
|
||||
using EveryThing.Models.Invoice;
|
||||
using EveryThing.Models.Vehicle;
|
||||
using static EveryThing.Pages.CodeTableVehicleFuelTypes.IndexModel;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using NuGet.Packaging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using static EveryThing.Pages.CodeTableItems.IndexModel;
|
||||
using static EveryThing.Pages.CodeTableVehicleFuelTypes.IndexModel;
|
||||
|
||||
namespace EveryThing.Pages.Projects
|
||||
{
|
||||
[Authorize(Roles = "Administrator,ProjecThingUser")]
|
||||
public class EditModel : PageModel
|
||||
{
|
||||
public class LinkToBuyersOrderData
|
||||
{
|
||||
public int IdProject { get; set; }
|
||||
public SelectList SelectListOrders { get; set; }
|
||||
public int IdOrder { get; set; }
|
||||
}
|
||||
|
||||
public class EditProjectPartData
|
||||
{
|
||||
public ProjectPartItem Item { get; set; }
|
||||
@@ -96,6 +104,12 @@ namespace EveryThing.Pages.Projects
|
||||
.OrderBy(x => x.InvoiceYear).ThenBy(x => x.InvoiceNumber)
|
||||
.ToListAsync();
|
||||
|
||||
Invoices.AddRange(await _context.Invoices
|
||||
.Include(x => x.Project)
|
||||
.Include(x => x.InvoiceInvoiceItem)
|
||||
.Where(x => x.IdProjectFk == id).ToArrayAsync());
|
||||
|
||||
|
||||
FilesProject = await _context.Files
|
||||
.Where(x => x.IdCompanyFk == user.IdCompanyFk
|
||||
&& x.IdReferenceFk == Project.IdProject
|
||||
@@ -820,5 +834,39 @@ namespace EveryThing.Pages.Projects
|
||||
|
||||
return new JsonResult(new { successful = true, error = "", idInvoice });
|
||||
}
|
||||
|
||||
public IActionResult OnGetLinkToProjectData(int idProject)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
var selListOrders = new SelectList(_context.Invoices.Include(x => x.Partner)
|
||||
.Where(x => x.Type == Invoice.InvoiceType.BuyersOrder && x.State == Invoice.InvoiceState.Offer)
|
||||
.OrderByDescending(x => x.InvoiceYear).ThenBy(x => x.InvoiceNumber).ToList(), "IdInvoice", "InvoiceNumberFormattedLong");
|
||||
|
||||
return Partial("ModalCreateLinkToBuyersOrders", new LinkToBuyersOrderData
|
||||
{
|
||||
SelectListOrders = selListOrders,
|
||||
IdProject = idProject
|
||||
});
|
||||
}
|
||||
|
||||
public IActionResult OnPostLinkProjectToBuyerOrder(int idProject, int idOrder)
|
||||
{
|
||||
var user = _userManager.GetUserAsync(User).Result;
|
||||
|
||||
var project = _context.Projects.FirstOrDefault(x => x.IdProject == idProject);
|
||||
if (project == null)
|
||||
return new JsonResult(new { successful = false, error = $"Project with ID {idProject} not exists!" });
|
||||
|
||||
var invoice = _context.Invoices.FirstOrDefault(x => x.IdInvoice == idOrder);
|
||||
|
||||
if (invoice == null)
|
||||
return new JsonResult(new { successful = false, error = $"Invoice with ID {idOrder} not exists!" });
|
||||
|
||||
invoice.IdProjectFk = project.IdProject;
|
||||
_context.SaveChanges();
|
||||
|
||||
return new JsonResult(new { successful = true, error = ""});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user