Compare commits
No commits in common. "e0727c69583f96e4a257fbe2b18079bb732c17b5" and "43a4cbf81e7a0e3f3e2ae49d77c715fc642e369d" have entirely different histories.
e0727c6958
...
43a4cbf81e
14
Program.cs
14
Program.cs
@ -22,8 +22,6 @@ using NHibernate.Driver;
|
|||||||
using FirmTracker_Server.Controllers;
|
using FirmTracker_Server.Controllers;
|
||||||
using FirmTracker_Server.nHibernate.Products;
|
using FirmTracker_Server.nHibernate.Products;
|
||||||
using FirmTracker_Server.nHibernate;
|
using FirmTracker_Server.nHibernate;
|
||||||
using FirmTracker_Server.Utilities.Converters;
|
|
||||||
using FirmTracker_Server.Utilities.Swagger;
|
|
||||||
|
|
||||||
namespace FirmTracker_Server
|
namespace FirmTracker_Server
|
||||||
{
|
{
|
||||||
@ -62,18 +60,10 @@ namespace FirmTracker_Server
|
|||||||
.AllowAnyHeader()
|
.AllowAnyHeader()
|
||||||
.AllowAnyMethod());
|
.AllowAnyMethod());
|
||||||
});
|
});
|
||||||
builder.Services.AddControllers()
|
builder.Services.AddControllers();
|
||||||
.AddJsonOptions(options =>
|
|
||||||
{
|
|
||||||
options.JsonSerializerOptions.Converters.Add(new DateTimeConverter());
|
|
||||||
});
|
|
||||||
;
|
|
||||||
|
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
builder.Services.AddSwaggerGen(c =>
|
builder.Services.AddSwaggerGen();
|
||||||
{
|
|
||||||
c.SchemaFilter<SwaggerDateTimeSchemaFilter>();
|
|
||||||
});
|
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
var configSwagger = new ConfigurationBuilder()
|
var configSwagger = new ConfigurationBuilder()
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Text.Json;
|
|
||||||
using System.Text.Json.Serialization;
|
|
||||||
|
|
||||||
namespace FirmTracker_Server.Utilities.Converters
|
|
||||||
{
|
|
||||||
public class DateTimeConverter : JsonConverter<DateTime>
|
|
||||||
{
|
|
||||||
private const string DateFormat = "yyyy-MM-ddTHH:mm";
|
|
||||||
|
|
||||||
public override DateTime Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
|
||||||
{
|
|
||||||
if (reader.TokenType == JsonTokenType.String)
|
|
||||||
{
|
|
||||||
if (DateTime.TryParseExact(reader.GetString(), DateFormat, null, System.Globalization.DateTimeStyles.None, out var date))
|
|
||||||
{
|
|
||||||
return date;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new JsonException("Invalid date format");
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options)
|
|
||||||
{
|
|
||||||
writer.WriteStringValue(value.ToString(DateFormat));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
using Microsoft.OpenApi.Any;
|
|
||||||
using Microsoft.OpenApi.Models;
|
|
||||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
|
||||||
|
|
||||||
namespace FirmTracker_Server.Utilities.Swagger
|
|
||||||
{
|
|
||||||
public class SwaggerDateTimeSchemaFilter : ISchemaFilter
|
|
||||||
{
|
|
||||||
public void Apply(OpenApiSchema schema, SchemaFilterContext context)
|
|
||||||
{
|
|
||||||
if (context.Type == typeof(DateTime) || context.Type == typeof(DateTime?))
|
|
||||||
{
|
|
||||||
schema.Format = "yyyy-MM-ddTHH:mm";
|
|
||||||
schema.Example = new OpenApiString(DateTime.Now.ToString("yyyy-MM-ddTHH:mm"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -16,14 +16,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
using FirmTracker_Server.nHibernate.Reports;
|
using FirmTracker_Server.nHibernate.Reports;
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace FirmTracker_Server.nHibernate.Expenses
|
namespace FirmTracker_Server.nHibernate.Expenses
|
||||||
{
|
{
|
||||||
public class Expense
|
public class Expense
|
||||||
{
|
{
|
||||||
public virtual int Id { get; set; }
|
public virtual int Id { get; set; }
|
||||||
[DataType(DataType.DateTime)]
|
|
||||||
public virtual DateTime Date { get; set; }
|
public virtual DateTime Date { get; set; }
|
||||||
public virtual decimal Value { get; set; }
|
public virtual decimal Value { get; set; }
|
||||||
public virtual string Description { get; set; }
|
public virtual string Description { get; set; }
|
||||||
|
@ -18,16 +18,13 @@
|
|||||||
using FirmTracker_Server.nHibernate.Expenses;
|
using FirmTracker_Server.nHibernate.Expenses;
|
||||||
using FirmTracker_Server.nHibernate.Transactions;
|
using FirmTracker_Server.nHibernate.Transactions;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace FirmTracker_Server.nHibernate.Reports
|
namespace FirmTracker_Server.nHibernate.Reports
|
||||||
{
|
{
|
||||||
public class Report
|
public class Report
|
||||||
{
|
{
|
||||||
public virtual int Id { get; set; }
|
public virtual int Id { get; set; }
|
||||||
[DataType(DataType.DateTime)]
|
|
||||||
public virtual DateTime FromDate { get; set; }
|
public virtual DateTime FromDate { get; set; }
|
||||||
[DataType(DataType.DateTime)]
|
|
||||||
public virtual DateTime ToDate { get; set; }
|
public virtual DateTime ToDate { get; set; }
|
||||||
public virtual decimal TotalIncome { get; set; }
|
public virtual decimal TotalIncome { get; set; }
|
||||||
public virtual decimal TotalExpenses { get; set; }
|
public virtual decimal TotalExpenses { get; set; }
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using FirmTracker_Server.nHibernate.Reports;
|
using FirmTracker_Server.nHibernate.Reports;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace FirmTracker_Server.nHibernate.Transactions
|
namespace FirmTracker_Server.nHibernate.Transactions
|
||||||
@ -10,7 +9,6 @@ namespace FirmTracker_Server.nHibernate.Transactions
|
|||||||
public class Transaction
|
public class Transaction
|
||||||
{
|
{
|
||||||
public virtual int Id { get; set; }
|
public virtual int Id { get; set; }
|
||||||
[DataType(DataType.DateTime)]
|
|
||||||
public virtual DateTime Date { get; set; }
|
public virtual DateTime Date { get; set; }
|
||||||
public virtual int EmployeeId { get; set; }
|
public virtual int EmployeeId { get; set; }
|
||||||
public virtual IList<TransactionProduct> TransactionProducts { get; set; } = new List<TransactionProduct>();
|
public virtual IList<TransactionProduct> TransactionProducts { get; set; } = new List<TransactionProduct>();
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using FirmTracker_Server.nHibernate.Reports;
|
using FirmTracker_Server.nHibernate.Reports;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace FirmTracker_Server.nHibernate.Transactions
|
namespace FirmTracker_Server.nHibernate.Transactions
|
||||||
@ -10,7 +9,6 @@ namespace FirmTracker_Server.nHibernate.Transactions
|
|||||||
public class Transaction2
|
public class Transaction2
|
||||||
{
|
{
|
||||||
public virtual int Id { get; set; }
|
public virtual int Id { get; set; }
|
||||||
[DataType(DataType.DateTime)]
|
|
||||||
public virtual DateTime Date { get; set; }
|
public virtual DateTime Date { get; set; }
|
||||||
public virtual int EmployeeId { get; set; }
|
public virtual int EmployeeId { get; set; }
|
||||||
public virtual IList<TransactionWithProducts> TransactionProducts { get; set; } = new List<TransactionWithProducts>();
|
public virtual IList<TransactionWithProducts> TransactionProducts { get; set; } = new List<TransactionWithProducts>();
|
||||||
|
Loading…
Reference in New Issue
Block a user