Лок. даты
This commit is contained in:
@@ -52,8 +52,8 @@ namespace TheBlacksmithVakulaBusinessLogic.Implementations
|
|||||||
public void CalculateSalaryByMounth(DateTime date)
|
public void CalculateSalaryByMounth(DateTime date)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("CalculateSalaryByMounth: {date}", date);
|
_logger.LogInformation("CalculateSalaryByMounth: {date}", date);
|
||||||
var startDate = new DateTime(date.Year, date.Month, 1);
|
var startDate = new DateTime(date.Year, date.Month, 1).ToUniversalTime();
|
||||||
var finishDate = new DateTime(date.Year, date.Month, DateTime.DaysInMonth(date.Year, date.Month));
|
var finishDate = new DateTime(date.Year, date.Month, DateTime.DaysInMonth(date.Year, date.Month)).ToUniversalTime();
|
||||||
var blacksmiths = _blacksmithStorageContract.GetList() ?? throw new NullListException();
|
var blacksmiths = _blacksmithStorageContract.GetList() ?? throw new NullListException();
|
||||||
foreach (var blacksmith in blacksmiths)
|
foreach (var blacksmith in blacksmiths)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ namespace TheBlacksmithVakulaContract.DataModels
|
|||||||
|
|
||||||
public string RankId { get; private set; } = rankId;
|
public string RankId { get; private set; } = rankId;
|
||||||
|
|
||||||
public DateTime BirthDate { get; private set; } = birthDate;
|
public DateTime BirthDate { get; private set; } = birthDate.ToUniversalTime();
|
||||||
|
|
||||||
public DateTime EmploymentDate { get; private set; } = employmentDate;
|
public DateTime EmploymentDate { get; private set; } = employmentDate.ToUniversalTime();
|
||||||
|
|
||||||
public bool IsDeleted { get; private set; } = isDeleted;
|
public bool IsDeleted { get; private set; } = isDeleted;
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace TheBlacksmithVakulaContract.DataModels
|
|||||||
|
|
||||||
public string BlacksmithId { get; private set; } = blacksmithId;
|
public string BlacksmithId { get; private set; } = blacksmithId;
|
||||||
|
|
||||||
public DateTime SalaryDate { get; private set; } = salaryDate;
|
public DateTime SalaryDate { get; private set; } = salaryDate.ToUniversalTime();
|
||||||
|
|
||||||
public double Salary { get; private set; } = blacksmithSalary;
|
public double Salary { get; private set; } = blacksmithSalary;
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ namespace TheBlacksmithVakulaDatabase
|
|||||||
public TheBlacksmithVakulaDbContext(IConfigurationDatabase configurationDatabase)
|
public TheBlacksmithVakulaDbContext(IConfigurationDatabase configurationDatabase)
|
||||||
{
|
{
|
||||||
_configurationDatabase = configurationDatabase;
|
_configurationDatabase = configurationDatabase;
|
||||||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
|
||||||
AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
|
|||||||
@@ -92,8 +92,8 @@ namespace TheBlacksmithVakulaTests.DataModelsTests
|
|||||||
Assert.That(blacksmith.Id, Is.EqualTo(id));
|
Assert.That(blacksmith.Id, Is.EqualTo(id));
|
||||||
Assert.That(blacksmith.FIO, Is.EqualTo(fio));
|
Assert.That(blacksmith.FIO, Is.EqualTo(fio));
|
||||||
Assert.That(blacksmith.RankId, Is.EqualTo(rankId));
|
Assert.That(blacksmith.RankId, Is.EqualTo(rankId));
|
||||||
Assert.That(blacksmith.BirthDate, Is.EqualTo(birthDate));
|
Assert.That(blacksmith.BirthDate, Is.EqualTo(birthDate.ToUniversalTime()));
|
||||||
Assert.That(blacksmith.EmploymentDate, Is.EqualTo(employmentDate));
|
Assert.That(blacksmith.EmploymentDate, Is.EqualTo(employmentDate.ToUniversalTime()));
|
||||||
Assert.That(blacksmith.IsDeleted, Is.EqualTo(isDelete));
|
Assert.That(blacksmith.IsDeleted, Is.EqualTo(isDelete));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ namespace TheBlacksmithVakulaTests.DataModelsTests
|
|||||||
Assert.Multiple(() =>
|
Assert.Multiple(() =>
|
||||||
{
|
{
|
||||||
Assert.That(salary.BlacksmithId, Is.EqualTo(id));
|
Assert.That(salary.BlacksmithId, Is.EqualTo(id));
|
||||||
Assert.That(salary.SalaryDate, Is.EqualTo(salaryDate));
|
Assert.That(salary.SalaryDate, Is.EqualTo(salaryDate.ToUniversalTime()));
|
||||||
Assert.That(salary.Salary, Is.EqualTo(salarySize));
|
Assert.That(salary.Salary, Is.EqualTo(salarySize));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
TheBlacksmithVakulaDbContext.InsertBlacksmithToDatabaseAndReturn(fio: "fio 3", birthDate: DateTime.UtcNow.AddYears(-20), isDeleted: true);
|
TheBlacksmithVakulaDbContext.InsertBlacksmithToDatabaseAndReturn(fio: "fio 3", birthDate: DateTime.UtcNow.AddYears(-20), isDeleted: true);
|
||||||
TheBlacksmithVakulaDbContext.InsertBlacksmithToDatabaseAndReturn(fio: "fio 4", birthDate: DateTime.UtcNow.AddYears(-19));
|
TheBlacksmithVakulaDbContext.InsertBlacksmithToDatabaseAndReturn(fio: "fio 4", birthDate: DateTime.UtcNow.AddYears(-19));
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/blacksmiths/getbirthdaterecords?fromDate={DateTime.UtcNow.AddYears(-21).AddMinutes(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddYears(-20).AddMinutes(1):MM/dd/yyyy HH:mm:ss}&includeDeleted=true"); //:MM/dd/yyyy HH:mm:ss
|
var response = await HttpClient.GetAsync($"/api/blacksmiths/getbirthdaterecords?fromDate={DateTime.Now.AddYears(-21).AddMinutes(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddYears(-20).AddMinutes(1):MM/dd/yyyy HH:mm:ss}&includeDeleted=true"); //:MM/dd/yyyy HH:mm:ss
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
||||||
var data = await GetModelFromResponseAsync<List<BlacksmithViewModel>>(response);
|
var data = await GetModelFromResponseAsync<List<BlacksmithViewModel>>(response);
|
||||||
@@ -169,7 +169,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
public async Task GetList_ByBirthDate_WhenDateIsIncorrect_ShouldBadRequest_Test()
|
public async Task GetList_ByBirthDate_WhenDateIsIncorrect_ShouldBadRequest_Test()
|
||||||
{
|
{
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/blacksmiths/getbirthdaterecords?fromDate={DateTime.UtcNow.AddMinutes(1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddMinutes(-1):MM/dd/yyyy HH:mm:ss}&includeDeleted=true");
|
var response = await HttpClient.GetAsync($"/api/blacksmiths/getbirthdaterecords?fromDate={DateTime.Now.AddMinutes(1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddMinutes(-1):MM/dd/yyyy HH:mm:ss}&includeDeleted=true");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
||||||
}
|
}
|
||||||
@@ -183,7 +183,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
TheBlacksmithVakulaDbContext.InsertBlacksmithToDatabaseAndReturn(fio: "fio 3", employmentDate: DateTime.UtcNow.AddDays(1), isDeleted: true);
|
TheBlacksmithVakulaDbContext.InsertBlacksmithToDatabaseAndReturn(fio: "fio 3", employmentDate: DateTime.UtcNow.AddDays(1), isDeleted: true);
|
||||||
TheBlacksmithVakulaDbContext.InsertBlacksmithToDatabaseAndReturn(fio: "fio 4", employmentDate: DateTime.UtcNow.AddDays(2));
|
TheBlacksmithVakulaDbContext.InsertBlacksmithToDatabaseAndReturn(fio: "fio 4", employmentDate: DateTime.UtcNow.AddDays(2));
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/blacksmiths/getemploymentrecords?fromDate={DateTime.UtcNow.AddDays(-1).AddMinutes(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(1).AddMinutes(1):MM/dd/yyyy HH:mm:ss}&includeDeleted=true");
|
var response = await HttpClient.GetAsync($"/api/blacksmiths/getemploymentrecords?fromDate={DateTime.Now.AddDays(-1).AddMinutes(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(1).AddMinutes(1):MM/dd/yyyy HH:mm:ss}&includeDeleted=true");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
||||||
var data = await GetModelFromResponseAsync<List<BlacksmithViewModel>>(response);
|
var data = await GetModelFromResponseAsync<List<BlacksmithViewModel>>(response);
|
||||||
@@ -198,7 +198,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
public async Task GetList_ByEmploymentDate_WhenDateIsIncorrect_ShouldBadRequest_Test()
|
public async Task GetList_ByEmploymentDate_WhenDateIsIncorrect_ShouldBadRequest_Test()
|
||||||
{
|
{
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/blacksmiths/getemploymentrecords?fromDate={DateTime.UtcNow.AddMinutes(1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddMinutes(-1):MM/dd/yyyy HH:mm:ss}&includeDeleted=true");
|
var response = await HttpClient.GetAsync($"/api/blacksmiths/getemploymentrecords?fromDate={DateTime.Now.AddMinutes(1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddMinutes(-1):MM/dd/yyyy HH:mm:ss}&includeDeleted=true");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(_blacksmithId, products: [(_productId, 10)]);
|
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(_blacksmithId, products: [(_productId, 10)]);
|
||||||
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(_blacksmithId, products: [(_productId, 10)]);
|
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(_blacksmithId, products: [(_productId, 10)]);
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/orders/getrecords?fromDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
var response = await HttpClient.GetAsync($"/api/orders/getrecords?fromDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
||||||
var data = await GetModelFromResponseAsync<List<OrderViewModel>>(response);
|
var data = await GetModelFromResponseAsync<List<OrderViewModel>>(response);
|
||||||
@@ -58,7 +58,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
public async Task GetList_WhenNoRecords_ShouldSuccess_Test()
|
public async Task GetList_WhenNoRecords_ShouldSuccess_Test()
|
||||||
{
|
{
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/orders/getrecords?fromDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
var response = await HttpClient.GetAsync($"/api/orders/getrecords?fromDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
||||||
var data = await GetModelFromResponseAsync<List<OrderViewModel>>(response);
|
var data = await GetModelFromResponseAsync<List<OrderViewModel>>(response);
|
||||||
@@ -78,7 +78,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(_blacksmithId, null, orderDate: DateTime.UtcNow.AddDays(1).AddMinutes(-3), products: [(_productId, 10)]);
|
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(_blacksmithId, null, orderDate: DateTime.UtcNow.AddDays(1).AddMinutes(-3), products: [(_productId, 10)]);
|
||||||
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(_blacksmithId, null, orderDate: DateTime.UtcNow.AddDays(1).AddMinutes(3), products: [(_productId, 10)]);
|
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(_blacksmithId, null, orderDate: DateTime.UtcNow.AddDays(1).AddMinutes(3), products: [(_productId, 10)]);
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/orders/getrecords?fromDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
var response = await HttpClient.GetAsync($"/api/orders/getrecords?fromDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
||||||
var data = await GetModelFromResponseAsync<List<OrderViewModel>>(response);
|
var data = await GetModelFromResponseAsync<List<OrderViewModel>>(response);
|
||||||
@@ -93,7 +93,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
public async Task GetList_ByPeriod_WhenDateIsIncorrect_ShouldBadRequest_Test()
|
public async Task GetList_ByPeriod_WhenDateIsIncorrect_ShouldBadRequest_Test()
|
||||||
{
|
{
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/orders/getrecords?fromDate={DateTime.UtcNow.AddDays(1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}");
|
var response = await HttpClient.GetAsync($"/api/orders/getrecords?fromDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
||||||
}
|
}
|
||||||
@@ -107,7 +107,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(_blacksmithId, _buyerId, products: [(_productId, 10)]);
|
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(_blacksmithId, _buyerId, products: [(_productId, 10)]);
|
||||||
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(blacksmith.Id, null, products: [(_productId, 10)]);
|
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(blacksmith.Id, null, products: [(_productId, 10)]);
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/orders/getblacksmithrecords?id={_blacksmithId}&fromDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
var response = await HttpClient.GetAsync($"/api/orders/getblacksmithrecords?id={_blacksmithId}&fromDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
||||||
var data = await GetModelFromResponseAsync<List<OrderViewModel>>(response);
|
var data = await GetModelFromResponseAsync<List<OrderViewModel>>(response);
|
||||||
@@ -126,7 +126,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
var blacksmith = TheBlacksmithVakulaDbContext.InsertBlacksmithToDatabaseAndReturn(fio: "Other blacksmith");
|
var blacksmith = TheBlacksmithVakulaDbContext.InsertBlacksmithToDatabaseAndReturn(fio: "Other blacksmith");
|
||||||
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(_blacksmithId, _buyerId, products: [(_productId, 10)]);
|
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(_blacksmithId, _buyerId, products: [(_productId, 10)]);
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/orders/getblacksmithrecords?id={blacksmith.Id}&fromDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
var response = await HttpClient.GetAsync($"/api/orders/getblacksmithrecords?id={blacksmith.Id}&fromDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
||||||
var data = await GetModelFromResponseAsync<List<OrderViewModel>>(response);
|
var data = await GetModelFromResponseAsync<List<OrderViewModel>>(response);
|
||||||
@@ -138,7 +138,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
public async Task GetList_ByBlacksmithId_WhenDateIsIncorrect_ShouldBadRequest_Test()
|
public async Task GetList_ByBlacksmithId_WhenDateIsIncorrect_ShouldBadRequest_Test()
|
||||||
{
|
{
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/orders/getblacksmithrecords?id={_blacksmithId}&fromDate={DateTime.UtcNow.AddDays(1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}");
|
var response = await HttpClient.GetAsync($"/api/orders/getblacksmithrecords?id={_blacksmithId}&fromDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
||||||
}
|
}
|
||||||
@@ -147,7 +147,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
public async Task GetList_ByBlacksmithId_WhenIdIsIncorrect_ShouldBadRequest_Test()
|
public async Task GetList_ByBlacksmithId_WhenIdIsIncorrect_ShouldBadRequest_Test()
|
||||||
{
|
{
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/orders/getblacksmithrecords?id=Id&fromDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
var response = await HttpClient.GetAsync($"/api/orders/getblacksmithrecords?id=Id&fromDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
||||||
}
|
}
|
||||||
@@ -162,7 +162,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(_blacksmithId, buyer.Id, products: [(_productId, 10)]);
|
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(_blacksmithId, buyer.Id, products: [(_productId, 10)]);
|
||||||
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(_blacksmithId, null, products: [(_productId, 10)]);
|
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(_blacksmithId, null, products: [(_productId, 10)]);
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/orders/getbuyerrecords?id={_buyerId}&fromDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
var response = await HttpClient.GetAsync($"/api/orders/getbuyerrecords?id={_buyerId}&fromDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
||||||
var data = await GetModelFromResponseAsync<List<OrderViewModel>>(response);
|
var data = await GetModelFromResponseAsync<List<OrderViewModel>>(response);
|
||||||
@@ -181,7 +181,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
var buyer = TheBlacksmithVakulaDbContext.InsertBuyerToDatabaseAndReturn(fio: "Other buyer", phoneNumber: "+8-888-888-88-88");
|
var buyer = TheBlacksmithVakulaDbContext.InsertBuyerToDatabaseAndReturn(fio: "Other buyer", phoneNumber: "+8-888-888-88-88");
|
||||||
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(_blacksmithId, _buyerId, products: [(_productId, 10)]);
|
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(_blacksmithId, _buyerId, products: [(_productId, 10)]);
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/orders/getbuyerrecords?id={buyer.Id}&fromDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
var response = await HttpClient.GetAsync($"/api/orders/getbuyerrecords?id={buyer.Id}&fromDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
||||||
var data = await GetModelFromResponseAsync<List<OrderViewModel>>(response);
|
var data = await GetModelFromResponseAsync<List<OrderViewModel>>(response);
|
||||||
@@ -193,7 +193,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
public async Task GetList_ByBuyerId_WhenDateIsIncorrect_ShouldBadRequest_Test()
|
public async Task GetList_ByBuyerId_WhenDateIsIncorrect_ShouldBadRequest_Test()
|
||||||
{
|
{
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/orders/getbuyerrecords?id={_buyerId}&fromDate={DateTime.UtcNow.AddDays(1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}");
|
var response = await HttpClient.GetAsync($"/api/orders/getbuyerrecords?id={_buyerId}&fromDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
||||||
}
|
}
|
||||||
@@ -202,7 +202,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
public async Task GetList_ByBuyerId_WhenIdIsIncorrect_ShouldBadRequest_Test()
|
public async Task GetList_ByBuyerId_WhenIdIsIncorrect_ShouldBadRequest_Test()
|
||||||
{
|
{
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/orders/getbuyerrecords?id=Id&fromDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
var response = await HttpClient.GetAsync($"/api/orders/getbuyerrecords?id=Id&fromDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
||||||
}
|
}
|
||||||
@@ -217,7 +217,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(_blacksmithId, null, products: [(product.Id, 1)]);
|
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(_blacksmithId, null, products: [(product.Id, 1)]);
|
||||||
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(_blacksmithId, null, products: [(product.Id, 1), (_productId, 10)]);
|
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(_blacksmithId, null, products: [(product.Id, 1), (_productId, 10)]);
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/orders/getproductrecords?id={_productId}&fromDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
var response = await HttpClient.GetAsync($"/api/orders/getproductrecords?id={_productId}&fromDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
||||||
var data = await GetModelFromResponseAsync<List<OrderViewModel>>(response);
|
var data = await GetModelFromResponseAsync<List<OrderViewModel>>(response);
|
||||||
@@ -236,7 +236,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
var product = TheBlacksmithVakulaDbContext.InsertProductToDatabaseAndReturn(_billetId, productName: "Other product");
|
var product = TheBlacksmithVakulaDbContext.InsertProductToDatabaseAndReturn(_billetId, productName: "Other product");
|
||||||
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(_blacksmithId, _buyerId, products: [(_productId, 10)]);
|
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(_blacksmithId, _buyerId, products: [(_productId, 10)]);
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/orders/getproductrecords?id={product.Id}&fromDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
var response = await HttpClient.GetAsync($"/api/orders/getproductrecords?id={product.Id}&fromDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
||||||
var data = await GetModelFromResponseAsync<List<OrderViewModel>>(response);
|
var data = await GetModelFromResponseAsync<List<OrderViewModel>>(response);
|
||||||
@@ -248,7 +248,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
public async Task GetList_ByProductId_WhenDateIsIncorrect_ShouldBadRequest_Test()
|
public async Task GetList_ByProductId_WhenDateIsIncorrect_ShouldBadRequest_Test()
|
||||||
{
|
{
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/orders/getproductrecords?id={_productId}&fromDate={DateTime.UtcNow.AddDays(1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}");
|
var response = await HttpClient.GetAsync($"/api/orders/getproductrecords?id={_productId}&fromDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
||||||
}
|
}
|
||||||
@@ -257,7 +257,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
public async Task GetList_ByProductId_WhenIdIsIncorrect_ShouldBadRequest_Test()
|
public async Task GetList_ByProductId_WhenIdIsIncorrect_ShouldBadRequest_Test()
|
||||||
{
|
{
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/orders/getproductrecords?id=Id&fromDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
var response = await HttpClient.GetAsync($"/api/orders/getproductrecords?id=Id&fromDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(blacksmith.Id, products: [(product1.Id, 10), (product2.Id, 10)]);
|
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(blacksmith.Id, products: [(product1.Id, 10), (product2.Id, 10)]);
|
||||||
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(blacksmith.Id, products: [(product1.Id, 10)]);
|
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(blacksmith.Id, products: [(product1.Id, 10)]);
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/report/getorders?fromDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
var response = await HttpClient.GetAsync($"/api/report/getorders?fromDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
||||||
var data = await GetModelFromResponseAsync<List<OrderViewModel>>(response);
|
var data = await GetModelFromResponseAsync<List<OrderViewModel>>(response);
|
||||||
@@ -70,7 +70,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
public async Task GetOrders_WhenDateIsIncorrect_ShouldBadRequest_Test()
|
public async Task GetOrders_WhenDateIsIncorrect_ShouldBadRequest_Test()
|
||||||
{
|
{
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/report/getorders?fromDate={DateTime.UtcNow.AddDays(1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}");
|
var response = await HttpClient.GetAsync($"/api/report/getorders?fromDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
||||||
}
|
}
|
||||||
@@ -88,7 +88,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
TheBlacksmithVakulaDbContext.InsertSalaryToDatabaseAndReturn(blacksmith2.Id, blacksmithSalary: 500, salaryDate: DateTime.UtcNow.AddDays(-5));
|
TheBlacksmithVakulaDbContext.InsertSalaryToDatabaseAndReturn(blacksmith2.Id, blacksmithSalary: 500, salaryDate: DateTime.UtcNow.AddDays(-5));
|
||||||
TheBlacksmithVakulaDbContext.InsertSalaryToDatabaseAndReturn(blacksmith2.Id, blacksmithSalary: 300, salaryDate: DateTime.UtcNow.AddDays(-3));
|
TheBlacksmithVakulaDbContext.InsertSalaryToDatabaseAndReturn(blacksmith2.Id, blacksmithSalary: 300, salaryDate: DateTime.UtcNow.AddDays(-3));
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/report/getsalary?fromDate={DateTime.UtcNow.AddDays(-7):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}");
|
var response = await HttpClient.GetAsync($"/api/report/getsalary?fromDate={DateTime.Now.AddDays(-7):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
||||||
var data = await GetModelFromResponseAsync<List<BlacksmithSalaryByPeriodViewModel>>(response);
|
var data = await GetModelFromResponseAsync<List<BlacksmithSalaryByPeriodViewModel>>(response);
|
||||||
@@ -105,7 +105,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
public async Task GetSalary_WhenDateIsIncorrect_ShouldBadRequest_Test()
|
public async Task GetSalary_WhenDateIsIncorrect_ShouldBadRequest_Test()
|
||||||
{
|
{
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/report/getsalary?fromDate={DateTime.UtcNow.AddDays(1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}");
|
var response = await HttpClient.GetAsync($"/api/report/getsalary?fromDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
||||||
}
|
}
|
||||||
@@ -139,7 +139,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(blacksmith.Id, products: [(product1.Id, 10), (product2.Id, 10)]);
|
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(blacksmith.Id, products: [(product1.Id, 10), (product2.Id, 10)]);
|
||||||
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(blacksmith.Id, products: [(product1.Id, 10)]);
|
TheBlacksmithVakulaDbContext.InsertOrderToDatabaseAndReturn(blacksmith.Id, products: [(product1.Id, 10)]);
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/report/loadorders?fromDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
var response = await HttpClient.GetAsync($"/api/report/loadorders?fromDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
||||||
//Assert
|
//Assert
|
||||||
await AssertStreamAsync(response, "file.xlsx");
|
await AssertStreamAsync(response, "file.xlsx");
|
||||||
}
|
}
|
||||||
@@ -148,7 +148,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
public async Task LoadOrders_WhenDateIsIncorrect_ShouldBadRequest_Test()
|
public async Task LoadOrders_WhenDateIsIncorrect_ShouldBadRequest_Test()
|
||||||
{
|
{
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/report/loadorders?fromDate={DateTime.UtcNow.AddDays(1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}");
|
var response = await HttpClient.GetAsync($"/api/report/loadorders?fromDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
||||||
}
|
}
|
||||||
@@ -166,7 +166,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
TheBlacksmithVakulaDbContext.InsertSalaryToDatabaseAndReturn(blacksmith2.Id, blacksmithSalary: 500, salaryDate: DateTime.UtcNow.AddDays(-5));
|
TheBlacksmithVakulaDbContext.InsertSalaryToDatabaseAndReturn(blacksmith2.Id, blacksmithSalary: 500, salaryDate: DateTime.UtcNow.AddDays(-5));
|
||||||
TheBlacksmithVakulaDbContext.InsertSalaryToDatabaseAndReturn(blacksmith2.Id, blacksmithSalary: 300, salaryDate: DateTime.UtcNow.AddDays(-3));
|
TheBlacksmithVakulaDbContext.InsertSalaryToDatabaseAndReturn(blacksmith2.Id, blacksmithSalary: 300, salaryDate: DateTime.UtcNow.AddDays(-3));
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/report/loadsalary?fromDate={DateTime.UtcNow.AddDays(-7):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}");
|
var response = await HttpClient.GetAsync($"/api/report/loadsalary?fromDate={DateTime.Now.AddDays(-7):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}");
|
||||||
//Assert
|
//Assert
|
||||||
await AssertStreamAsync(response, "file.pdf");
|
await AssertStreamAsync(response, "file.pdf");
|
||||||
}
|
}
|
||||||
@@ -175,7 +175,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
public async Task LoadSalary_WhenDateIsIncorrect_ShouldBadRequest_Test()
|
public async Task LoadSalary_WhenDateIsIncorrect_ShouldBadRequest_Test()
|
||||||
{
|
{
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/report/loadsalary?fromDate={DateTime.UtcNow.AddDays(1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}");
|
var response = await HttpClient.GetAsync($"/api/report/loadsalary?fromDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
TheBlacksmithVakulaDbContext.InsertSalaryToDatabaseAndReturn(blacksmith.Id);
|
TheBlacksmithVakulaDbContext.InsertSalaryToDatabaseAndReturn(blacksmith.Id);
|
||||||
TheBlacksmithVakulaDbContext.InsertSalaryToDatabaseAndReturn(blacksmith.Id);
|
TheBlacksmithVakulaDbContext.InsertSalaryToDatabaseAndReturn(blacksmith.Id);
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/salaries/getrecords?fromDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
var response = await HttpClient.GetAsync($"/api/salaries/getrecords?fromDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
||||||
var data = await GetModelFromResponseAsync<List<SalaryViewModel>>(response);
|
var data = await GetModelFromResponseAsync<List<SalaryViewModel>>(response);
|
||||||
@@ -45,7 +45,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
public async Task GetList_WhenNoRecords_ShouldSuccess_Test()
|
public async Task GetList_WhenNoRecords_ShouldSuccess_Test()
|
||||||
{
|
{
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/salaries/getrecords?fromDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
var response = await HttpClient.GetAsync($"/api/salaries/getrecords?fromDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
||||||
var data = await GetModelFromResponseAsync<List<SalaryViewModel>>(response);
|
var data = await GetModelFromResponseAsync<List<SalaryViewModel>>(response);
|
||||||
@@ -68,7 +68,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
TheBlacksmithVakulaDbContext.InsertSalaryToDatabaseAndReturn(blacksmith.Id, salaryDate: DateTime.UtcNow.AddDays(1).AddMinutes(5));
|
TheBlacksmithVakulaDbContext.InsertSalaryToDatabaseAndReturn(blacksmith.Id, salaryDate: DateTime.UtcNow.AddDays(1).AddMinutes(5));
|
||||||
TheBlacksmithVakulaDbContext.InsertSalaryToDatabaseAndReturn(blacksmith.Id, salaryDate: DateTime.UtcNow.AddDays(-2));
|
TheBlacksmithVakulaDbContext.InsertSalaryToDatabaseAndReturn(blacksmith.Id, salaryDate: DateTime.UtcNow.AddDays(-2));
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/salaries/getrecords?fromDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
var response = await HttpClient.GetAsync($"/api/salaries/getrecords?fromDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
||||||
var data = await GetModelFromResponseAsync<List<SalaryViewModel>>(response);
|
var data = await GetModelFromResponseAsync<List<SalaryViewModel>>(response);
|
||||||
@@ -83,7 +83,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
public async Task GetList_WhenDateIsIncorrect_ShouldBadRequest_Test()
|
public async Task GetList_WhenDateIsIncorrect_ShouldBadRequest_Test()
|
||||||
{
|
{
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/salaries/getblacksmithrecords?fromDate={DateTime.UtcNow.AddDays(1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}");
|
var response = await HttpClient.GetAsync($"/api/salaries/getblacksmithrecords?fromDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
||||||
}
|
}
|
||||||
@@ -98,7 +98,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
TheBlacksmithVakulaDbContext.InsertSalaryToDatabaseAndReturn(blacksmith1.Id);
|
TheBlacksmithVakulaDbContext.InsertSalaryToDatabaseAndReturn(blacksmith1.Id);
|
||||||
TheBlacksmithVakulaDbContext.InsertSalaryToDatabaseAndReturn(blacksmith2.Id);
|
TheBlacksmithVakulaDbContext.InsertSalaryToDatabaseAndReturn(blacksmith2.Id);
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/salaries/getblacksmithrecords?fromDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(1):MM/dd/yyyy HH:mm:ss}&id={blacksmith1.Id}");
|
var response = await HttpClient.GetAsync($"/api/salaries/getblacksmithrecords?fromDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}&id={blacksmith1.Id}");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
||||||
var data = await GetModelFromResponseAsync<List<SalaryViewModel>>(response);
|
var data = await GetModelFromResponseAsync<List<SalaryViewModel>>(response);
|
||||||
@@ -123,7 +123,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
TheBlacksmithVakulaDbContext.InsertSalaryToDatabaseAndReturn(blacksmith2.Id, salaryDate: DateTime.UtcNow.AddDays(1).AddMinutes(-5));
|
TheBlacksmithVakulaDbContext.InsertSalaryToDatabaseAndReturn(blacksmith2.Id, salaryDate: DateTime.UtcNow.AddDays(1).AddMinutes(-5));
|
||||||
TheBlacksmithVakulaDbContext.InsertSalaryToDatabaseAndReturn(blacksmith1.Id, salaryDate: DateTime.UtcNow.AddDays(-2));
|
TheBlacksmithVakulaDbContext.InsertSalaryToDatabaseAndReturn(blacksmith1.Id, salaryDate: DateTime.UtcNow.AddDays(-2));
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/salaries/getblacksmithrecords?fromDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(1):MM/dd/yyyy HH:mm:ss}&id={blacksmith1.Id}");
|
var response = await HttpClient.GetAsync($"/api/salaries/getblacksmithrecords?fromDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}&id={blacksmith1.Id}");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
||||||
var data = await GetModelFromResponseAsync<List<SalaryViewModel>>(response);
|
var data = await GetModelFromResponseAsync<List<SalaryViewModel>>(response);
|
||||||
@@ -141,7 +141,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
//Arrange
|
//Arrange
|
||||||
var blacksmith = TheBlacksmithVakulaDbContext.InsertBlacksmithToDatabaseAndReturn(fio: "name 1");
|
var blacksmith = TheBlacksmithVakulaDbContext.InsertBlacksmithToDatabaseAndReturn(fio: "name 1");
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/salaries/getblacksmithrecords?fromDate={DateTime.UtcNow.AddDays(1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}&id={blacksmith.Id}");
|
var response = await HttpClient.GetAsync($"/api/salaries/getblacksmithrecords?fromDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}&id={blacksmith.Id}");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
||||||
}
|
}
|
||||||
@@ -150,7 +150,7 @@ namespace TheBlacksmithVakulaTests.WebApiControllersTests
|
|||||||
public async Task GetList_ByBlacksmith_WhenIdIsNotGuid_ShouldBadRequest_Test()
|
public async Task GetList_ByBlacksmith_WhenIdIsNotGuid_ShouldBadRequest_Test()
|
||||||
{
|
{
|
||||||
//Act
|
//Act
|
||||||
var response = await HttpClient.GetAsync($"/api/salaries/getblacksmithrecords?fromDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(1):MM/dd/yyyy HH:mm:ss}&id=id");
|
var response = await HttpClient.GetAsync($"/api/salaries/getblacksmithrecords?fromDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}&id=id");
|
||||||
//Assert
|
//Assert
|
||||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,9 @@ namespace TheBlacksmithVakulaWebApi.Adapters
|
|||||||
var config = new MapperConfiguration(cfg =>
|
var config = new MapperConfiguration(cfg =>
|
||||||
{
|
{
|
||||||
cfg.CreateMap<BlacksmithBindingModel, BlacksmithDataModel>();
|
cfg.CreateMap<BlacksmithBindingModel, BlacksmithDataModel>();
|
||||||
cfg.CreateMap<BlacksmithDataModel, BlacksmithViewModel>();
|
cfg.CreateMap<BlacksmithDataModel, BlacksmithViewModel>()
|
||||||
|
.ForMember(x => x.BirthDate, x => x.MapFrom(src => src.BirthDate.ToLocalTime()))
|
||||||
|
.ForMember(x => x.EmploymentDate, x => x.MapFrom(src => src.EmploymentDate.ToLocalTime()));
|
||||||
});
|
});
|
||||||
_mapper = new Mapper(config);
|
_mapper = new Mapper(config);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace TheBlacksmithVakulaWebApi.Adapters
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return OrderOperationResponse.OK([.. _orderBusinessLogicContract.GetAllOrderByPeriod(fromDate, toDate).Select(x => _mapper.Map<OrderViewModel>(x))]);
|
return OrderOperationResponse.OK([.. _orderBusinessLogicContract.GetAllOrderByPeriod(fromDate.ToUniversalTime(), toDate.ToUniversalTime()).Select(x => _mapper.Map<OrderViewModel>(x))]);
|
||||||
}
|
}
|
||||||
catch (IncorrectDatesException ex)
|
catch (IncorrectDatesException ex)
|
||||||
{
|
{
|
||||||
@@ -63,7 +63,7 @@ namespace TheBlacksmithVakulaWebApi.Adapters
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return OrderOperationResponse.OK([.. _orderBusinessLogicContract.GetAllOrderByBlacksmithByPeriod(id, fromDate, toDate).Select(x => _mapper.Map<OrderViewModel>(x))]);
|
return OrderOperationResponse.OK([.. _orderBusinessLogicContract.GetAllOrderByBlacksmithByPeriod(id, fromDate.ToUniversalTime(), toDate.ToUniversalTime()).Select(x => _mapper.Map<OrderViewModel>(x))]);
|
||||||
}
|
}
|
||||||
catch (IncorrectDatesException ex)
|
catch (IncorrectDatesException ex)
|
||||||
{
|
{
|
||||||
@@ -96,7 +96,7 @@ namespace TheBlacksmithVakulaWebApi.Adapters
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return OrderOperationResponse.OK([.. _orderBusinessLogicContract.GetAllOrderByBuyerByPeriod(id, fromDate, toDate).Select(x => _mapper.Map<OrderViewModel>(x))]);
|
return OrderOperationResponse.OK([.. _orderBusinessLogicContract.GetAllOrderByBuyerByPeriod(id, fromDate.ToUniversalTime(), toDate.ToUniversalTime()).Select(x => _mapper.Map<OrderViewModel>(x))]);
|
||||||
}
|
}
|
||||||
catch (IncorrectDatesException ex)
|
catch (IncorrectDatesException ex)
|
||||||
{
|
{
|
||||||
@@ -129,7 +129,7 @@ namespace TheBlacksmithVakulaWebApi.Adapters
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return OrderOperationResponse.OK([.. _orderBusinessLogicContract.GetAllOrderByProductByPeriod(id, fromDate, toDate).Select(x => _mapper.Map<OrderViewModel>(x))]);
|
return OrderOperationResponse.OK([.. _orderBusinessLogicContract.GetAllOrderByProductByPeriod(id, fromDate.ToUniversalTime(), toDate.ToUniversalTime()).Select(x => _mapper.Map<OrderViewModel>(x))]);
|
||||||
}
|
}
|
||||||
catch (IncorrectDatesException ex)
|
catch (IncorrectDatesException ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ namespace TheBlacksmithVakulaWebApi.Adapters
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return ReportOperationResponse.OK((await _reportContract.GetDataOrderByPeriodAsync(dateStart, dateFinish, ct)).Select(x => _mapper.Map<OrderViewModel>(x)).ToList());
|
return ReportOperationResponse.OK((await _reportContract.GetDataOrderByPeriodAsync(dateStart.ToUniversalTime(), dateFinish.ToUniversalTime(), ct)).Select(x => _mapper.Map<OrderViewModel>(x)).ToList());
|
||||||
}
|
}
|
||||||
catch (IncorrectDatesException ex)
|
catch (IncorrectDatesException ex)
|
||||||
{
|
{
|
||||||
@@ -85,7 +85,7 @@ namespace TheBlacksmithVakulaWebApi.Adapters
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return ReportOperationResponse.OK((await _reportContract.GetDataSalaryByPeriodAsync(dateStart, dateFinish, ct)).Select(x => _mapper.Map<BlacksmithSalaryByPeriodViewModel>(x)).ToList());
|
return ReportOperationResponse.OK((await _reportContract.GetDataSalaryByPeriodAsync(dateStart.ToUniversalTime(), dateFinish.ToUniversalTime(), ct)).Select(x => _mapper.Map<BlacksmithSalaryByPeriodViewModel>(x)).ToList());
|
||||||
}
|
}
|
||||||
catch (IncorrectDatesException ex)
|
catch (IncorrectDatesException ex)
|
||||||
{
|
{
|
||||||
@@ -136,7 +136,7 @@ namespace TheBlacksmithVakulaWebApi.Adapters
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return SendStream(await _reportContract.CreateDocumentOrdersByPeriodAsync(dateStart, dateFinish, ct), "orders.xslx");
|
return SendStream(await _reportContract.CreateDocumentOrdersByPeriodAsync(dateStart.ToUniversalTime(), dateFinish.ToUniversalTime(), ct), "orders.xslx");
|
||||||
}
|
}
|
||||||
catch (IncorrectDatesException ex)
|
catch (IncorrectDatesException ex)
|
||||||
{
|
{
|
||||||
@@ -164,7 +164,7 @@ namespace TheBlacksmithVakulaWebApi.Adapters
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return SendStream(await _reportContract.CreateDocumentSalaryByPeriodAsync(dateStart, dateFinish, ct), "salary.pdf");
|
return SendStream(await _reportContract.CreateDocumentSalaryByPeriodAsync(dateStart.ToUniversalTime(), dateFinish.ToUniversalTime(), ct), "salary.pdf");
|
||||||
}
|
}
|
||||||
catch (IncorrectDatesException ex)
|
catch (IncorrectDatesException ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ namespace TheBlacksmithVakulaWebApi.Adapters
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
var config = new MapperConfiguration(cfg =>
|
var config = new MapperConfiguration(cfg =>
|
||||||
{
|
{
|
||||||
cfg.CreateMap<SalaryDataModel, SalaryViewModel>();
|
cfg.CreateMap<SalaryDataModel, SalaryViewModel>()
|
||||||
|
.ForMember(x => x.SalaryDate, x => x.MapFrom(src => src.SalaryDate.ToLocalTime()));
|
||||||
});
|
});
|
||||||
_mapper = new Mapper(config);
|
_mapper = new Mapper(config);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user