zmiany
This commit is contained in:
parent
ba4f8a717c
commit
b9dd32ee4d
@ -2,8 +2,8 @@
|
|||||||
{
|
{
|
||||||
public class AuthenticationSettings
|
public class AuthenticationSettings
|
||||||
{
|
{
|
||||||
public string JwtSecKey { get; set; }
|
public string JwtSecKey { get; set; }
|
||||||
public int JwtExpireDays { get; set; }
|
public int JwtExpireDays { get; set; }
|
||||||
public string JwtIssuer { get; set; }
|
public string JwtIssuer { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,13 @@ namespace FirmTracker_Server.Controllers
|
|||||||
{
|
{
|
||||||
private readonly IExpenseRepository _expenseRepository;
|
private readonly IExpenseRepository _expenseRepository;
|
||||||
private readonly ITransactionRepository _transactionRepository;
|
private readonly ITransactionRepository _transactionRepository;
|
||||||
|
private readonly IProductRepository _productRepository;
|
||||||
|
|
||||||
public PdfController(IExpenseRepository expenseRepository, ITransactionRepository transactionRepository)
|
public PdfController(IExpenseRepository expenseRepository, ITransactionRepository transactionRepository, IProductRepository productRepository)
|
||||||
{
|
{
|
||||||
_expenseRepository = expenseRepository;
|
_expenseRepository = expenseRepository;
|
||||||
_transactionRepository = transactionRepository;
|
_transactionRepository = transactionRepository;
|
||||||
|
_productRepository = productRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("download")]
|
[HttpGet("download")]
|
||||||
@ -112,8 +114,9 @@ namespace FirmTracker_Server.Controllers
|
|||||||
// Main header
|
// Main header
|
||||||
page.Header()
|
page.Header()
|
||||||
.Text("Raport transakcji")
|
.Text("Raport transakcji")
|
||||||
.FontSize(20)
|
.FontSize(22)
|
||||||
.SemiBold()
|
.SemiBold()
|
||||||
|
.FontColor(Colors.Blue.Medium)
|
||||||
.AlignCenter();
|
.AlignCenter();
|
||||||
|
|
||||||
// Summary section
|
// Summary section
|
||||||
@ -122,16 +125,18 @@ namespace FirmTracker_Server.Controllers
|
|||||||
column.Spacing(10);
|
column.Spacing(10);
|
||||||
|
|
||||||
column.Item().Text($"Transakcje od ({startDate:yyyy-MM-dd} do {endDate:yyyy-MM-dd})")
|
column.Item().Text($"Transakcje od ({startDate:yyyy-MM-dd} do {endDate:yyyy-MM-dd})")
|
||||||
.FontSize(16).Underline();
|
.FontSize(16)
|
||||||
|
.Underline()
|
||||||
|
.FontColor(Colors.Grey.Medium);
|
||||||
|
|
||||||
// Add table header
|
// Add table header
|
||||||
column.Item().Row(row =>
|
column.Item().Row(row =>
|
||||||
{
|
{
|
||||||
row.RelativeItem().Text("Data").SemiBold();
|
row.RelativeItem().Text("Data").SemiBold().FontColor(Colors.Blue.Darken1);
|
||||||
row.RelativeItem().Text("Typ płatności").SemiBold();
|
row.RelativeItem().Text("Typ płatności").SemiBold().FontColor(Colors.Blue.Darken1);
|
||||||
row.RelativeItem().Text("Kwota razem").SemiBold();
|
row.RelativeItem().Text("Kwota razem").SemiBold().FontColor(Colors.Blue.Darken1);
|
||||||
row.RelativeItem().Text("Rabat").SemiBold();
|
row.RelativeItem().Text("Rabat").SemiBold().FontColor(Colors.Blue.Darken1);
|
||||||
row.RelativeItem().Text("Opis").SemiBold();
|
row.RelativeItem().Text("Opis").SemiBold().FontColor(Colors.Blue.Darken1);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Populate table rows with transaction data
|
// Populate table rows with transaction data
|
||||||
@ -153,13 +158,15 @@ namespace FirmTracker_Server.Controllers
|
|||||||
|
|
||||||
if (products.Any())
|
if (products.Any())
|
||||||
{
|
{
|
||||||
column.Item().Text("Produkty:").SemiBold();
|
column.Item().Text("Produkty:").SemiBold().FontColor(Colors.Blue.Medium);
|
||||||
foreach (var product in products)
|
foreach (var product in products)
|
||||||
{
|
{
|
||||||
|
var productQuery = _productRepository.GetProduct(product.Id);
|
||||||
column.Item().Row(productRow =>
|
column.Item().Row(productRow =>
|
||||||
{
|
{
|
||||||
productRow.RelativeItem().Text($"Nazwa produktu: {product.ProductName}");
|
productRow.RelativeItem().Text($"Nazwa produktu: {productQuery.Name}");
|
||||||
productRow.RelativeItem().Text($"Ilość: {product.Quantity}");
|
productRow.RelativeItem().Text($"Ilość: {product.Quantity}");
|
||||||
|
productRow.RelativeItem().Text($"Cena 1 szt. bez rabatu: {productQuery.Price.ToString("F2")}");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -171,8 +178,8 @@ namespace FirmTracker_Server.Controllers
|
|||||||
.AlignCenter()
|
.AlignCenter()
|
||||||
.Text(text =>
|
.Text(text =>
|
||||||
{
|
{
|
||||||
text.Span("Wygenerowano przez automat FT: ");
|
text.Span("Wygenerowano przez automat FT: ").FontColor(Colors.Grey.Medium);
|
||||||
text.Span(DateTime.Now.ToString("yyyy-MM-dd")).SemiBold();
|
text.Span(DateTime.Now.ToString("yyyy-MM-dd")).SemiBold().FontColor(Colors.Grey.Medium);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}).GeneratePdf(ms);
|
}).GeneratePdf(ms);
|
||||||
@ -200,8 +207,9 @@ namespace FirmTracker_Server.Controllers
|
|||||||
// Main header
|
// Main header
|
||||||
page.Header()
|
page.Header()
|
||||||
.Text("Raport wydatków")
|
.Text("Raport wydatków")
|
||||||
.FontSize(20)
|
.FontSize(22)
|
||||||
.SemiBold()
|
.SemiBold()
|
||||||
|
.FontColor(Colors.Green.Medium)
|
||||||
.AlignCenter();
|
.AlignCenter();
|
||||||
|
|
||||||
// Summary section
|
// Summary section
|
||||||
@ -211,18 +219,20 @@ namespace FirmTracker_Server.Controllers
|
|||||||
|
|
||||||
column.Item().Row(row =>
|
column.Item().Row(row =>
|
||||||
{
|
{
|
||||||
row.RelativeItem().Text($"Łączne wydatki: {totalExpenses:C}").FontSize(14).Bold();
|
row.RelativeItem().Text($"Łączne wydatki: {totalExpenses:C}").FontSize(14).Bold().FontColor(Colors.Green.Darken1);
|
||||||
row.RelativeItem().Text($"Średnie wydatki dzienne: {averageExpense:C}").FontSize(14).Bold();
|
row.RelativeItem().Text($"Średnie wydatki dzienne: {averageExpense:C}").FontSize(14).Bold().FontColor(Colors.Green.Darken1);
|
||||||
});
|
});
|
||||||
|
|
||||||
column.Item().Text($"Szczegóły wydatków od ({startDate:yyyy-MM-dd} do {endDate:yyyy-MM-dd})")
|
column.Item().Text($"Szczegóły wydatków od ({startDate:yyyy-MM-dd} do {endDate:yyyy-MM-dd})")
|
||||||
.FontSize(16).Underline();
|
.FontSize(16)
|
||||||
|
.Underline()
|
||||||
|
.FontColor(Colors.Grey.Medium);
|
||||||
|
|
||||||
column.Item().Row(row =>
|
column.Item().Row(row =>
|
||||||
{
|
{
|
||||||
row.RelativeItem().Text("Data").SemiBold();
|
row.RelativeItem().Text("Data").SemiBold().FontColor(Colors.Green.Darken1);
|
||||||
row.RelativeItem().Text("Kwota").SemiBold();
|
row.RelativeItem().Text("Kwota").SemiBold().FontColor(Colors.Green.Darken1);
|
||||||
row.RelativeItem().Text("Opis").SemiBold();
|
row.RelativeItem().Text("Opis").SemiBold().FontColor(Colors.Green.Darken1);
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach (var expense in expenses)
|
foreach (var expense in expenses)
|
||||||
@ -236,12 +246,13 @@ namespace FirmTracker_Server.Controllers
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Footer with generation date
|
||||||
page.Footer()
|
page.Footer()
|
||||||
.AlignCenter()
|
.AlignCenter()
|
||||||
.Text(text =>
|
.Text(text =>
|
||||||
{
|
{
|
||||||
text.Span("Wygenerowano przez automat FT: ");
|
text.Span("Wygenerowano przez automat FT: ").FontColor(Colors.Grey.Medium);
|
||||||
text.Span(DateTime.Now.ToString("yyyy-MM-dd")).SemiBold();
|
text.Span(DateTime.Now.ToString("yyyy-MM-dd")).SemiBold().FontColor(Colors.Grey.Medium);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}).GeneratePdf(ms);
|
}).GeneratePdf(ms);
|
||||||
@ -249,5 +260,7 @@ namespace FirmTracker_Server.Controllers
|
|||||||
return ms.ToArray();
|
return ms.ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ namespace FirmTracker_Server.Controllers
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var userId = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier)?.Value ;
|
var userId = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier)?.Value;
|
||||||
|
|
||||||
var dayDetails = _workdayCRUD.GetDayDetailsForLoggedUser(int.Parse(userId), date);
|
var dayDetails = _workdayCRUD.GetDayDetailsForLoggedUser(int.Parse(userId), date);
|
||||||
return Ok(dayDetails);
|
return Ok(dayDetails);
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
{
|
{
|
||||||
public class CreateUserDto
|
public class CreateUserDto
|
||||||
{
|
{
|
||||||
public string Login { get; set; }
|
public required string Login { get; set; }
|
||||||
public string Password { get; set; }
|
public required string Password { get; set; }
|
||||||
public string Email { get; set; }
|
public required string Email { get; set; }
|
||||||
public string Role { get; set; }
|
public required string Role { get; set; }
|
||||||
public bool NewEncryption { get; set; } = true;
|
public bool NewEncryption { get; set; } = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,9 @@ namespace FirmTracker_Server.Models
|
|||||||
{
|
{
|
||||||
public class DayDetailsDto
|
public class DayDetailsDto
|
||||||
{
|
{
|
||||||
public string Email { get; set; }
|
public required string Email { get; set; }
|
||||||
public DateTime Date { get; set; }
|
public DateTime Date { get; set; }
|
||||||
public string TotalWorkedHours { get; set; }
|
public required string TotalWorkedHours { get; set; }
|
||||||
public List<Workday> WorkdayDetails { get; set; }
|
public required List<Workday> WorkdayDetails { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
8
Models/UpdatePasswordDto.cs
Normal file
8
Models/UpdatePasswordDto.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
namespace FirmTracker_Server.Models
|
||||||
|
{
|
||||||
|
public class UpdatePasswordDto
|
||||||
|
{
|
||||||
|
public string Email { get; set; }
|
||||||
|
public string Password { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -179,6 +179,7 @@ namespace FirmTracker_Server
|
|||||||
services.AddScoped<IPasswordHasher<User>, PasswordHasher<User>>();
|
services.AddScoped<IPasswordHasher<User>, PasswordHasher<User>>();
|
||||||
services.AddScoped<IExpenseRepository, ExpenseRepository>();
|
services.AddScoped<IExpenseRepository, ExpenseRepository>();
|
||||||
services.AddScoped<ITransactionRepository, TransactionRepository>();
|
services.AddScoped<ITransactionRepository, TransactionRepository>();
|
||||||
|
services.AddScoped<IProductRepository, ProductRepository>();
|
||||||
// services.AddScoped<IWorkdayRepository, WorkdayRepository>();
|
// services.AddScoped<IWorkdayRepository, WorkdayRepository>();
|
||||||
services.AddMvc();
|
services.AddMvc();
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@ using szyfrowanie;
|
|||||||
using FirmTracker_Server.nHibernate;
|
using FirmTracker_Server.nHibernate;
|
||||||
using NHibernate;
|
using NHibernate;
|
||||||
using NHibernate.Criterion;
|
using NHibernate.Criterion;
|
||||||
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||||
|
using NHibernate.Type;
|
||||||
|
|
||||||
namespace FirmTracker_Server.Services
|
namespace FirmTracker_Server.Services
|
||||||
{
|
{
|
||||||
@ -24,6 +26,7 @@ namespace FirmTracker_Server.Services
|
|||||||
int AddUser(CreateUserDto dto);
|
int AddUser(CreateUserDto dto);
|
||||||
string CreateTokenJwt(LoginDto dto);
|
string CreateTokenJwt(LoginDto dto);
|
||||||
IEnumerable<string> GetAllUserEmails();
|
IEnumerable<string> GetAllUserEmails();
|
||||||
|
bool UpdatePassword(UpdatePasswordDto dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UserService : IUserService
|
public class UserService : IUserService
|
||||||
@ -44,6 +47,10 @@ namespace FirmTracker_Server.Services
|
|||||||
SimplerAES = new SimplerAES();
|
SimplerAES = new SimplerAES();
|
||||||
//SessionFactory = sessionFactory;
|
//SessionFactory = sessionFactory;
|
||||||
}
|
}
|
||||||
|
public bool UpdatePassword(UpdatePasswordDto dto)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
public IEnumerable<string> GetAllUserEmails()
|
public IEnumerable<string> GetAllUserEmails()
|
||||||
{
|
{
|
||||||
using (var session = SessionFactory.OpenSession())
|
using (var session = SessionFactory.OpenSession())
|
||||||
|
67
TestClass.cs
67
TestClass.cs
@ -237,6 +237,73 @@ namespace FirmTracker_Server
|
|||||||
expenseCrud.AddExpense(expense1);
|
expenseCrud.AddExpense(expense1);
|
||||||
expenseCrud.AddExpense(expense2);
|
expenseCrud.AddExpense(expense2);
|
||||||
expenseCrud.AddExpense(expense3);
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
expenseCrud.AddExpense(expense3);
|
||||||
|
|
||||||
|
|
||||||
List<TransactionProduct> testTransactionProducts = new List<TransactionProduct> {
|
List<TransactionProduct> testTransactionProducts = new List<TransactionProduct> {
|
||||||
new TransactionProduct { ProductID =17, Quantity = 3 },
|
new TransactionProduct { ProductID =17, Quantity = 3 },
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Transactions;
|
||||||
using FirmTracker_Server.nHibernate.Expenses;
|
using FirmTracker_Server.nHibernate.Expenses;
|
||||||
|
using FirmTracker_Server.nHibernate.Products;
|
||||||
using FirmTracker_Server.nHibernate.Transactions;
|
using FirmTracker_Server.nHibernate.Transactions;
|
||||||
using NHibernate;
|
using NHibernate;
|
||||||
|
using Transaction = FirmTracker_Server.nHibernate.Transactions.Transaction;
|
||||||
|
|
||||||
namespace FirmTracker_Server.nHibernate
|
namespace FirmTracker_Server.nHibernate
|
||||||
{
|
{
|
||||||
|
public interface IProductRepository
|
||||||
|
{
|
||||||
|
Product GetProduct(int id);
|
||||||
|
}
|
||||||
|
|
||||||
public interface IExpenseRepository
|
public interface IExpenseRepository
|
||||||
{
|
{
|
||||||
List<Expense> GetAllExpenses();
|
List<Expense> GetAllExpenses();
|
||||||
@ -25,6 +33,17 @@ namespace FirmTracker_Server.nHibernate
|
|||||||
void DeleteTransaction(int transactionId);
|
void DeleteTransaction(int transactionId);
|
||||||
List<TransactionProduct> GetTransactionProductsForTransactions(List<int> transactionIds);
|
List<TransactionProduct> GetTransactionProductsForTransactions(List<int> transactionIds);
|
||||||
}
|
}
|
||||||
|
public class ProductRepository : IProductRepository
|
||||||
|
{
|
||||||
|
public Product GetProduct(int id)
|
||||||
|
{
|
||||||
|
using (var session = SessionFactory.OpenSession())
|
||||||
|
{
|
||||||
|
return session.Get<Product>(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class TransactionRepository : ITransactionRepository
|
public class TransactionRepository : ITransactionRepository
|
||||||
{
|
{
|
||||||
// Retrieve all transactions
|
// Retrieve all transactions
|
||||||
|
Loading…
Reference in New Issue
Block a user