Odstranjenn projekt

dodan vnos pozicije fakture
This commit is contained in:
David Štaleker
2023-05-13 16:42:01 +02:00
parent 03b92525d7
commit a45fe73754
76 changed files with 407 additions and 37538 deletions

View File

@@ -2,25 +2,31 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using DocumentFormat.OpenXml.ExtendedProperties;
using EveryThing.Data;
using EveryThing.Models;
using EveryThing.Models.CodeTable;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
namespace EveryThing.Pages.AdministrationCompanies
{
[Authorize(Roles = "Administrator")]
//[Authorize(Roles = "Administrator")]
public class SetupModel : PageModel
{
private readonly ApplicationDbContext _context;
private readonly UserManager<IdentityApplicationUser> _userManager;
private readonly SignInManager<IdentityApplicationUser> _signInManager;
private readonly RoleManager<IdentityApplicationRole> _roleManager;
private readonly ILogger<SetupModel> _logger;
public SetupModel(UserManager<IdentityApplicationUser> userManager, SignInManager<IdentityApplicationUser> signInManager, ILogger<SetupModel> logger, RoleManager<IdentityApplicationRole> roleManager)
public SetupModel(ApplicationDbContext context, UserManager<IdentityApplicationUser> userManager, SignInManager<IdentityApplicationUser> signInManager, ILogger<SetupModel> logger, RoleManager<IdentityApplicationRole> roleManager)
{
_context = context;
_userManager = userManager;
_signInManager = signInManager;
_logger = logger;
@@ -30,10 +36,38 @@ namespace EveryThing.Pages.AdministrationCompanies
public async Task<IActionResult> OnGetAsync()
{
//TODO osnovno podjetje?
var adminCompany = _context.CodeTableCompanies.FirstOrDefault(x => x.Title == "AdminCompany");
if (adminCompany == null)
{
var countrySlo = _context.CodeTableCountries.FirstAsync(x => x.Code == "SI");
adminCompany = new CodeTableCompany
{
Title = "AdminCompany",
Active = true,
IdCountryFk = countrySlo.Id,
City = "Ravne na Koroškem",
Street = "Ulica",
HouseNumber = "1",
PostNumber = 2380,
Post = "Pošta",
TaxNumber = "xxxxx",
RegistrationNumber = "xxxxx",
Email = "email@email.com",
Bank = "SI",
Iban = "SI",
SwiftBic = "SI",
Phone = "000 000 000",
Ceo = "Admin"
};
_context.CodeTableCompanies.Add(adminCompany);
await _context.SaveChangesAsync();
}
var rolesDefinitions = new List<(string RoleName, string RoleDescription)>
{
("TransportThingUser", "TransporThing uporabniki"),
("ProjecThingUser", "ProjecThing uporabniki"),
("InvoicingUser", "Fakturiranje uporabniki"),
("Administrator", "Administratorji"),
};
@@ -52,7 +86,9 @@ namespace EveryThing.Pages.AdministrationCompanies
}
}
if (_userManager.FindByNameAsync("admin") == null)
var user = await _userManager.FindByNameAsync("admin");
if (user == null)
{
IdentityApplicationUser identityApplicationUser = new IdentityApplicationUser
{
@@ -68,7 +104,7 @@ namespace EveryThing.Pages.AdministrationCompanies
PhoneNumber = "123456789",
PhoneNumberConfirmed = true,
Active = true,
IdCompanyFk = 1
IdCompanyFk = adminCompany.IdCompany
};
var result = await _userManager.CreateAsync(identityApplicationUser, "Master#Admin22!");