Skip to content

Commit

Permalink
🔧 Same Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
muqimjon committed Jan 31, 2024
1 parent 765fc4b commit 156f319
Show file tree
Hide file tree
Showing 29 changed files with 154 additions and 116 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using EcoLink.Application.ProjectManagementApps.Commands.CreateProjectManagement;
using EcoLink.Application.RepresentationApps.Commands.CreateRepresentation;

namespace EcoLink.Application.Commons.Mappers;
namespace EcoLink.Application.Commons.Mappers;

public class MappingProfile : Profile
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public record UpdateEntrepreneurshipStatusCommand : IRequest<EntrepreneurshipApp
public UpdateEntrepreneurshipStatusCommand(UpdateEntrepreneurshipStatusCommand command)
{
UserId = command.UserId;
IsOld = command.IsOld;
}

public long UserId { get; set; }
Expand All @@ -16,7 +17,7 @@ public class UpdateEntrepreneurshipStatusCommandHandler(IMapper mapper, IReposit
{
public async Task<EntrepreneurshipAppResultDto> Handle(UpdateEntrepreneurshipStatusCommand request, CancellationToken cancellationToken)
{
var entity = await repository.SelectAsync(e => e.UserId == request.UserId) ??
var entity = repository.SelectAll(e => e.UserId == request.UserId).OrderBy(e => e.Id).LastOrDefault() ??
throw new NotFoundException($"{nameof(EntrepreneurshipApp)} is not found with {nameof(request.UserId)} = {request.UserId}");

mapper.Map(request, entity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public record UpdateInvestmentStatusCommand : IRequest<InvestmentAppResultDto>
public UpdateInvestmentStatusCommand(UpdateInvestmentStatusCommand command)
{
UserId = command.UserId;
IsOld = command.IsOld;
}

public long UserId { get; set; }
Expand All @@ -16,7 +17,7 @@ public class UpdateInvestmentStatusCommandHandler(IMapper mapper, IRepository<In
{
public async Task<InvestmentAppResultDto> Handle(UpdateInvestmentStatusCommand request, CancellationToken cancellationToken)
{
var entity = await repository.SelectAsync(e => e.UserId == request.UserId) ??
var entity = repository.SelectAll(e => e.UserId == request.UserId).OrderBy(e => e.Id).LastOrDefault() ??
throw new NotFoundException($"{nameof(InvestmentApp)} is not found with {nameof(request.UserId)} = {request.UserId}");

mapper.Map(request, entity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public record UpdateProjectManagementStatusCommand : IRequest<ProjectManagementA
public UpdateProjectManagementStatusCommand(UpdateProjectManagementStatusCommand command)
{
UserId = command.UserId;
IsOld = command.IsOld;
}

public long UserId { get; set; }
Expand All @@ -16,7 +17,7 @@ public class UpdateProjectManagementStatusCommandHandler(IMapper mapper, IReposi
{
public async Task<ProjectManagementAppResultDto> Handle(UpdateProjectManagementStatusCommand request, CancellationToken cancellationToken)
{
var entity = await repository.SelectAsync(e => e.UserId == request.UserId) ??
var entity = repository.SelectAll(e => e.UserId == request.UserId).OrderBy(e => e.Id).LastOrDefault() ??
throw new NotFoundException($"{nameof(ProjectManagementApp)} is not found with {nameof(request.UserId)} = {request.UserId}");

mapper.Map(request, entity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public record UpdateRepresentationStatusCommand : IRequest<RepresentationAppResu
public UpdateRepresentationStatusCommand(UpdateRepresentationStatusCommand command)
{
UserId = command.UserId;
IsOld = command.IsOld;
}

public long UserId { get; set; }
Expand All @@ -16,7 +17,7 @@ public class UpdateRepresentationStatusCommandHandler(IMapper mapper, IRepositor
{
public async Task<RepresentationAppResultDto> Handle(UpdateRepresentationStatusCommand request, CancellationToken cancellationToken)
{
var entity = await repository.SelectAsync(e => e.UserId == request.UserId) ??
var entity = repository.SelectAll(e => e.UserId == request.UserId).OrderBy(e => e.Id).LastOrDefault() ??
throw new NotFoundException($"{nameof(RepresentationApp)} is not found with {nameof(request.UserId)} = {request.UserId}");

mapper.Map(request, entity);
Expand Down
17 changes: 9 additions & 8 deletions src/backend/EcoLink.Infrastructure/DependencyInjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static IServiceCollection AddInfrastructureServices(
{
// Add database
services.AddDbContext<AppDbContext>(options =>
options.UseNpgsql(configuration.GetConnectionString("DefaultConnection")));
options.UseNpgsql(configuration.GetConnectionString(name: "DefaultConnection")));

// Add sheets service
#region Add Sheets configure
Expand All @@ -29,24 +29,25 @@ public static IServiceCollection AddInfrastructureServices(

var properties = typeof(GoogleAuthSettings).GetProperties();
foreach (var property in properties)
property.SetValue(googleAuth, configuration[property.Name] ?? string.Empty);

var googleAuthJson = JsonConvert.SerializeObject(googleAuth);
property.SetValue(obj: googleAuth, value: configuration[property.Name] ?? string.Empty);
#endregion

services.AddSingleton(new SheetsConfigure()
{
SpreadsheetId = configuration.GetConnectionString("SpreadsheetId")!,
SpreadsheetId = configuration.GetConnectionString(name: "SpreadsheetId")!,
Service = new SheetsService(new BaseClientService.Initializer()
{
HttpClientInitializer = GoogleCredential.FromJson(json: googleAuthJson)
HttpClientInitializer = GoogleCredential.FromJson(
json: JsonConvert.SerializeObject(googleAuth))
}),
Sheets = JsonConvert.DeserializeObject<Sheets>(
value: configuration["Sheets"]!)!
});
#endregion

// Add repositories
services.AddScoped(typeof(IRepository<>), typeof(Repository<>));
services.AddScoped(typeof(ISheetsRepository<>), typeof(SheetsRepository<>));
services.AddScoped(serviceType: typeof(IRepository<>), implementationType: typeof(Repository<>));
services.AddScoped(serviceType: typeof(ISheetsRepository<>), implementationType: typeof(SheetsRepository<>));

return services;
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;

#nullable disable

namespace EcoLink.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class InitialMigrate : Migration
public partial class InitialMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
Expand Down Expand Up @@ -73,6 +72,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
AssetsInvested = table.Column<string>(type: "text", nullable: false),
Phone = table.Column<string>(type: "text", nullable: false),
Email = table.Column<string>(type: "text", nullable: false),
IsOld = table.Column<bool>(type: "boolean", nullable: false),
UserId = table.Column<long>(type: "bigint", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
Expand Down Expand Up @@ -103,6 +103,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
InvestmentAmount = table.Column<string>(type: "text", nullable: false),
Phone = table.Column<string>(type: "text", nullable: false),
Email = table.Column<string>(type: "text", nullable: false),
IsOld = table.Column<bool>(type: "boolean", nullable: false),
UserId = table.Column<long>(type: "bigint", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
Expand Down Expand Up @@ -137,6 +138,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
Purpose = table.Column<string>(type: "text", nullable: false),
Phone = table.Column<string>(type: "text", nullable: false),
Email = table.Column<string>(type: "text", nullable: false),
IsOld = table.Column<bool>(type: "boolean", nullable: false),
UserId = table.Column<long>(type: "bigint", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
Expand Down Expand Up @@ -171,6 +173,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
Purpose = table.Column<string>(type: "text", nullable: false),
Phone = table.Column<string>(type: "text", nullable: false),
Email = table.Column<string>(type: "text", nullable: false),
IsOld = table.Column<bool>(type: "boolean", nullable: false),
UserId = table.Column<long>(type: "bigint", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<bool>("IsDeleted")
.HasColumnType("boolean");
b.Property<bool>("IsOld")
.HasColumnType("boolean");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("text");
Expand Down Expand Up @@ -131,6 +134,9 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<bool>("IsDeleted")
.HasColumnType("boolean");
b.Property<bool>("IsOld")
.HasColumnType("boolean");
b.Property<string>("LastName")
.IsRequired()
.HasColumnType("text");
Expand Down Expand Up @@ -198,6 +204,9 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<bool>("IsDeleted")
.HasColumnType("boolean");
b.Property<bool>("IsOld")
.HasColumnType("boolean");
b.Property<string>("Languages")
.IsRequired()
.HasColumnType("text");
Expand Down Expand Up @@ -277,6 +286,9 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<bool>("IsDeleted")
.HasColumnType("boolean");
b.Property<bool>("IsOld")
.HasColumnType("boolean");
b.Property<string>("Languages")
.IsRequired()
.HasColumnType("text");
Expand Down
4 changes: 2 additions & 2 deletions src/backend/EcoLink.Infrastructure/Models/Sheets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
public class Sheets
{
public string Investment { get; set; } = string.Empty;
public string Entrepreneur { get; set; } = string.Empty;
public string Representation { get; set; } = string.Empty;
public string ProjectManager { get; set; } = string.Empty;
public string Entrepreneurship { get; set; } = string.Empty;
public string ProjectManagement { get; set; } = string.Empty;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ public async Task InsertAsync(T entity)

var sheet = entity switch
{
InvestmentAppForSheetsDto => "Investment!A:I",
EntrepreneurshipAppForSheetsDto => "Entrepreneurship!A:L",
RepresentationAppForSheetsDto => "Representation!A:L",
ProjectManagementAppForSheetsDto => "ProjectManagement!A:K",
InvestmentAppForSheetsDto => config.Sheets.Investment,
RepresentationAppForSheetsDto => config.Sheets.Representation,
EntrepreneurshipAppForSheetsDto => config.Sheets.Entrepreneurship,
ProjectManagementAppForSheetsDto => config.Sheets.ProjectManagement,
_ => throw new InvalidOperationException($"Unsupported entity type for send Google Sheets: {entity.GetType()}")
};

Expand All @@ -30,11 +30,7 @@ public async Task InsertAsync(T entity)
foreach (var property in properties)
oblist.Add(property.GetValue(entity)!);

var valueRange = new ValueRange
{
Values = new List<IList<object>> { oblist }
};

var valueRange = new ValueRange { Values = new List<IList<object>> { oblist } };
var appendRequest = config.Service.Spreadsheets.Values.Append(valueRange, config.SpreadsheetId, sheet);
appendRequest.ValueInputOption = SpreadsheetsResource.ValuesResource.AppendRequest.ValueInputOptionEnum.USERENTERED;
await appendRequest.ExecuteAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public async Task<IActionResult> UpdateStatus(UpdateInvestmentStatusCommand comm
public async Task<IActionResult> Get(long id, CancellationToken cancellationToken)
=> Ok(new Response { Data = await mediator.Send(new GetInvestmentAppQuery(id), cancellationToken) });

[HttpGet("get-all-by-user-userId/{userId:long}")]
[HttpGet("get-all-by-user-user-id/{userId:long}")]
[ProducesResponseType(typeof(IEnumerable<InvestmentAppResultDto>), StatusCodes.Status200OK)]
public async Task<IActionResult> GetAllByUserId(long userId, CancellationToken cancellationToken)
=> Ok(new Response { Data = await mediator.Send(new GetAllInvestmentAppsByUserIdQuery(userId), cancellationToken) });
Expand Down
21 changes: 6 additions & 15 deletions src/backend/EcoLink.WebApi/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,11 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ConnectionStrings": {
"DefaultConnection": "host=localhost;port=5432;uid=postgres;password=root;database=EcoLinkDb",
"SpreadSheetId": "1u6yMk5jfrc6E2C5xNKaVbThk-QbDz8xWVoVKm84k_QY"
"Sheets": {
"Investment": "Investment!A:I",
"Entrepreneur": "Entrepreneurship!A:L",
"Representation": "Representation!A:L",
"ProjectManager": "ProjectManagement!A:K"
},
"type": "service_account",
"project_id": "economy-assembly-requests",
"private_key_id": "0482da6609c5431edc9f7f295a07394ee75549ba",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDyulzEvgYLv5Xm\nWybpqy77bcdz7ZtmVqyStQumtWcxL4Bno/DkIL1n4FmYEE8I4iQmIk1X1TY5ZhTE\ndci643eL+Zjmos1SjgFTUMbyrFg4pHWdRldvijAfTIyV3DxKznN1K5ZzKjb0clTf\neDKd+gZxi39vEiWK802bLwaIyhLWAuuBJ80/+TwpdBrzBiZgQFOpkgW8xKlVcNSK\nQDTEO1dlzsYzZ6RSTX0Yxv8iFYecBWy1qJzICwFpB6THfQosSc+U88/WC1vbaJ90\nyL9GXxG6YnL6NcUlhWxSjLvRO9HRm61or93ZfGL93kuZ7YSbRuPKJA6RdX4ak1I5\ndFdIMYz9AgMBAAECggEAGvMnLq78g9xrO87eFK6tgjwPm6cDjIrOEWHpn8JfaT4h\nbyBsNCAQd5KY0AHrjIxzQAqp9LkXEqtrXd7IATwVP2Tgnabwzhw3OHVtCW+qQeu8\npVA0kA1TR35b053G0fV3K0jCJRpITL7O/prdX93tTjkTVpU4tuNJuBOyEYkCK2Gj\nQaC6CCPTe8Tc/+/62vCCduo1d3hqqVpAeYg/kctdKHS+7xmuK1zXr1lRXSloHxnu\nFwqw5ywo68bHhgogiB3qxim8d/4GFZTEnAi9RzV5lL66N+gmGjlUe/4yNM8bckCz\nmc/1ww7fmgSr1Z+6yxZECr/JZbPm3EEGMYRmIzd9HwKBgQD8KGXnJzUNs1q7dIkN\np9NS1b+95CzevP019gjPubm/KjipIrXLDRtu+rV+FOs650KIgwlmivTi4555aJgW\nnfBRuepRWjPNLOId5YR4C69SZNhWiyf8iH3XbG00Rrc4syF4a/VwuCNofsnfBRKK\nq7X2NnkMfvQFYbbCZoNaRQe0pwKBgQD2bS5XR/e36b812I39uKRCca0Cfxy9E4U7\n5tm4Po9aNrMSbZsPHUyLmqEXRzki6O8briubSRBGmGtklSOpDNRrpW/0zz2ZbRMw\n8pcRR6RfnUymW+/ufbPgfj4hbQZN40dkYGVfLhigHkkCKfQQVd9g+PHXZa62jG5b\nWVUXsZKRuwKBgQCW94TTGOktk7T9yC6J63GdBXYvtV2b2WBsHyp1W4e2yQt1T9+x\net5y2k0w+EtBT9XIr1NAfm9RK9/kZlewKs0H0RxVqoCbFYUnSxO9X5mO5euUHOpK\nylk1UagsBS6LFswyMciXvNcOJ+Kq0HmiZl2h1Ekyzws/8Zme2AtKT0vmvwKBgQDt\nM/NjeJbupUW1Ixqqm80hWCLdQFX9eojJPFFelHmQsQ52MqMLTXyc9N8TdS9+dxGS\nZ3j6JL5R9e2KCDUnSH5AkCLQV5xHz0Kl3x2jOH70uolJqT2vJ7i540sTCcsDtj7G\nVDPABrMVjZFhT9jq0H4Q7hB88hfXCB5COB88i2U2eQKBgQDGt2mCiiIh0GToeYpK\nyvrX8HAAp2F8E9WvtvDju9RMn+T6MNCEzxhr/3UqSUue/hHvyZpYu6+FYnsSOqae\nlCfvnf2tGh+mwW8pFN02Ai11zNpjiptWcQ1ktoGBKP3xMXtK/U0NVGphtrYxrTER\nrlQeYsdbzQNdv5tK/+k88Dirmw==\n-----END PRIVATE KEY-----\n",
"client_email": "uzbekistan@economy-assembly-requests.iam.gserviceaccount.com",
"client_id": "118366901482866054939",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/uzbekistan%40economy-assembly-requests.iam.gserviceaccount.com",
"universe_domain": "googleapis.com"
"AllowedHosts": "*"
}
8 changes: 4 additions & 4 deletions src/frontend/EcoLink.ApiService/DependencyInjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ public static IServiceCollection AddApiServices(this IServiceCollection services
{ client.BaseAddress = new Uri($"{baseLink}api/users/"); });

services.AddHttpClient<IInvestmentAppService, InvestmentAppService>(client =>
{ client.BaseAddress = new Uri($"{baseLink}api/InvestmentApps/"); });
{ client.BaseAddress = new Uri($"{baseLink}api/investment-apps/"); });

services.AddHttpClient<IRepresentationAppService, RepresentationAppService>(client =>
{ client.BaseAddress = new Uri($"{baseLink}api/RepresentationApps/"); });
{ client.BaseAddress = new Uri($"{baseLink}api/representation-apps/"); });

services.AddHttpClient<IEntrepreneurshipAppService, EntrepreneurshipAppService>(client =>
{ client.BaseAddress = new Uri($"{baseLink}api/EntrepreneurshipApps/"); });
{ client.BaseAddress = new Uri($"{baseLink}api/entrepreneurship-apps/"); });

services.AddHttpClient<IProjectManagementAppService, ProjectManagementAppService>(client =>
{ client.BaseAddress = new Uri($"{baseLink}api/ProjectManagementApps/"); });
{ client.BaseAddress = new Uri($"{baseLink}api/projectManagement-apps/"); });

return services;
}
Expand Down
Loading

0 comments on commit 156f319

Please sign in to comment.