generated from moevm/nsql-clean-tempate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into koroleva/serverCommunication
- Loading branch information
Showing
48 changed files
with
1,685 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using Warehouse2.Models; | ||
using Warehouse2.Services; | ||
|
||
namespace Warehouse2.Controllers | ||
{ | ||
[ApiController] | ||
[Route("[controller]")] | ||
public class CellsController : ControllerBase | ||
{ | ||
private readonly CellsService _cellsService; | ||
|
||
public CellsController(CellsService cellsService) | ||
{ | ||
_cellsService = cellsService; | ||
} | ||
|
||
|
||
[HttpGet] | ||
public async Task<List<Cell>> GetDocsIndices() => | ||
await _cellsService.ListDocsAsync(); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Core.Arango.Protocol; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Warehouse2.Models; | ||
using Warehouse2.Services; | ||
|
||
namespace Warehouse2.Controllers | ||
{ | ||
[ApiController] | ||
[Route("[controller]")] | ||
public class EventsController : ControllerBase | ||
{ | ||
private readonly EventsService _eventsService; | ||
|
||
public EventsController(EventsService eventsService) | ||
{ | ||
_eventsService = eventsService; | ||
} | ||
|
||
|
||
[HttpGet] | ||
public async Task<List<Event>> GetDocsIndices() => | ||
await _eventsService.ListDocsAsync(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using Warehouse2.Models; | ||
using Warehouse2.Services; | ||
|
||
namespace Warehouse2.Controllers | ||
{ | ||
[ApiController] | ||
[Route("[controller]")] | ||
public class UsersController : ControllerBase | ||
{ | ||
private readonly UsersService _usersService; | ||
|
||
public UsersController(UsersService usersService) | ||
{ | ||
_usersService = usersService; | ||
} | ||
|
||
|
||
[HttpGet] | ||
public async Task<List<User>> GetDocsIndices() => | ||
await _usersService.ListDocsAsync(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using Warehouse2.Models; | ||
using Warehouse2.Services; | ||
|
||
namespace Warehouse2.Controllers | ||
{ | ||
[ApiController] | ||
[Route("[controller]")] | ||
public class WarehousesController | ||
{ | ||
private readonly WarehousesService _warehousesService; | ||
|
||
public WarehousesController(WarehousesService warehousesService) | ||
{ | ||
_warehousesService = warehousesService; | ||
} | ||
|
||
|
||
[HttpGet] | ||
public async Task<List<Warehouse>> GetDocsIndices() => | ||
await _warehousesService.ListDocsAsync(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
| ||
|
||
namespace Warehouse2.Models | ||
{ | ||
public class Cell | ||
{ | ||
public Cell() {} | ||
|
||
public string? Id { get; set; } | ||
|
||
public string? warehouseId { get; set; } | ||
|
||
public int cellNum { get; set; } | ||
|
||
public int tierNum { get; set; } | ||
|
||
public bool isFree { get; set; } | ||
|
||
public int endOfRent { get; set; } | ||
|
||
public float tariffPerDay { get; set; } | ||
|
||
public float size { get; set; } | ||
|
||
public string[]? listOfEventIds { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Microsoft.VisualBasic; | ||
|
||
namespace Warehouse2.Models | ||
{ | ||
public class Event | ||
{ | ||
|
||
public Event(string action, string description, int dat) | ||
{ | ||
Action = action; | ||
Descritpion = description; | ||
DateAndTime = dat; | ||
} | ||
|
||
public string? Id { get; set; } | ||
|
||
public string? CellId { get; set; } | ||
|
||
public string? UserId { get; set; } | ||
|
||
public string Action { get; set; } | ||
|
||
public int DateAndTime { get; set; } | ||
|
||
public string Descritpion { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
| ||
|
||
namespace Warehouse2.Models | ||
{ | ||
public class User | ||
{ | ||
public User() { } | ||
|
||
public string Id { get; set; } | ||
|
||
public string? NameSurnamePatronymic { get; set; } | ||
|
||
public string role { get; set; } | ||
|
||
public string login { get; set; } | ||
|
||
public string password { get; set; } | ||
|
||
public int birthday { get; set; } | ||
|
||
public int regDate { get; set; } | ||
|
||
public int? editDate { get; set; } | ||
|
||
public int indebtedness { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace Warehouse2.Models | ||
{ | ||
public class Warehouse | ||
{ | ||
Warehouse() { } | ||
|
||
public string? Id { get; set; } | ||
|
||
public string? address { get; set; } | ||
|
||
public int? capacity { get; set; } | ||
|
||
public string? chiefId { get; set; } | ||
|
||
public string[]? cells { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace Warehouse2.Models | ||
{ | ||
public class WarehouseDatabaseSettings | ||
{ | ||
public string ConnectionString { get; set; } = null!; | ||
|
||
public string DatabaseName { get; set; } = null!; | ||
|
||
public string CellsCollectionName { get; set; } = null!; | ||
|
||
public string EventCollectionName { get; set; } = null!; | ||
|
||
public string UsersCollectionName { get; set; } = null!; | ||
|
||
public string WarehousesCollectionName { get; set; } = null!; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Core.Arango; | ||
using Warehouse2.Models; | ||
using Warehouse2.Services; | ||
|
||
|
||
var builder = WebApplication.CreateBuilder(args); | ||
|
||
// Add services to the container. | ||
|
||
builder.Services.Configure<WarehouseDatabaseSettings>( | ||
builder.Configuration.GetSection("WarehouseDatabase")); | ||
|
||
builder.Services.AddSingleton<EventsService>(); | ||
builder.Services.AddSingleton<CellsService>(); | ||
builder.Services.AddSingleton<UsersService>(); | ||
builder.Services.AddSingleton<WarehousesService>(); | ||
//builder.Services.AddArango(builder.Configuration.GetConnectionString("ConnctingString")); | ||
|
||
builder.Services.AddControllers(); | ||
builder.Services.AddSwaggerGen(); | ||
|
||
var app = builder.Build(); | ||
|
||
// Configure the HTTP request pipeline. | ||
if (app.Environment.IsDevelopment()) | ||
{ | ||
app.UseSwagger(); | ||
app.UseSwaggerUI(); | ||
} | ||
|
||
app.UseAuthorization(); | ||
|
||
app.MapControllers(); | ||
|
||
app.Run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/launchsettings.json", | ||
"iisSettings": { | ||
"windowsAuthentication": false, | ||
"anonymousAuthentication": true, | ||
"iisExpress": { | ||
"applicationUrl": "http://localhost:38294", | ||
"sslPort": 0 | ||
} | ||
}, | ||
"profiles": { | ||
"http": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"launchUrl": "swagger", | ||
"applicationUrl": "http://localhost:5085", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"IIS Express": { | ||
"commandName": "IISExpress", | ||
"launchBrowser": true, | ||
"launchUrl": "swagger", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Core.Arango; | ||
using Microsoft.Extensions.Options; | ||
using Warehouse2.Models; | ||
|
||
namespace Warehouse2.Services | ||
{ | ||
public class CellsService | ||
{ | ||
private readonly IArangoContext _arango; | ||
|
||
private readonly string _dbName; | ||
|
||
private readonly string _collectionName; | ||
|
||
public CellsService(IOptions<WarehouseDatabaseSettings> WarehouseDatabaseSettings) | ||
{ | ||
_arango = new ArangoContext(WarehouseDatabaseSettings.Value.ConnectionString); | ||
|
||
_dbName = WarehouseDatabaseSettings.Value.DatabaseName; | ||
|
||
_collectionName = WarehouseDatabaseSettings.Value.CellsCollectionName; | ||
|
||
} | ||
|
||
|
||
public async Task<List<Cell>> ListDocsAsync() | ||
{ | ||
return await _arango.Query.FindAsync<Cell>(_dbName, _collectionName, $"x"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Core.Arango; | ||
using Core.Arango.Modules; | ||
using Core.Arango.Protocol; | ||
using Microsoft.Extensions.Options; | ||
using Newtonsoft.Json.Linq; | ||
using System.Collections.Generic; | ||
using System; | ||
using Warehouse2.Models; | ||
|
||
namespace Warehouse2.Services | ||
{ | ||
public class EventsService | ||
{ | ||
private readonly IArangoContext _arango; | ||
|
||
private readonly string _dbName; | ||
|
||
private readonly string _collectionName; | ||
|
||
public EventsService(IOptions<WarehouseDatabaseSettings> WarehouseDatabaseSettings) | ||
{ | ||
_arango = new ArangoContext(WarehouseDatabaseSettings.Value.ConnectionString); | ||
|
||
_dbName = WarehouseDatabaseSettings.Value.DatabaseName; | ||
|
||
_collectionName = WarehouseDatabaseSettings.Value.EventCollectionName; | ||
|
||
} | ||
|
||
/* public async Task<List<Event>> GetAsync() => | ||
await _arango.Document.GetManyAsync<Event>(_dbName, _collectionName, new List<string> { "28163" }); // only for one now !!!!! | ||
*/ | ||
public async Task<List<Event>> ListDocsAsync() | ||
{ | ||
//FormattableString filter = $"x"; | ||
return await _arango.Query.FindAsync<Event>(_dbName, _collectionName, $"x"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Core.Arango; | ||
using Microsoft.Extensions.Options; | ||
using Warehouse2.Models; | ||
|
||
namespace Warehouse2.Services | ||
{ | ||
public class UsersService | ||
{ | ||
private readonly IArangoContext _arango; | ||
|
||
private readonly string _dbName; | ||
|
||
private readonly string _collectionName; | ||
|
||
public UsersService(IOptions<WarehouseDatabaseSettings> WarehouseDatabaseSettings) | ||
{ | ||
_arango = new ArangoContext(WarehouseDatabaseSettings.Value.ConnectionString); | ||
|
||
_dbName = WarehouseDatabaseSettings.Value.DatabaseName; | ||
|
||
_collectionName = WarehouseDatabaseSettings.Value.UsersCollectionName; | ||
|
||
} | ||
|
||
|
||
public async Task<List<User>> ListDocsAsync() | ||
{ | ||
return await _arango.Query.FindAsync<User>(_dbName, _collectionName, $"x"); | ||
} | ||
} | ||
} |
Oops, something went wrong.