TotechsStrypper
TotechsStrypper
CC#
Created by TotechsStrypper on 10/9/2024 in #help
✅ Test keep returning 503 while postman give 200
No description
16 replies
CC#
Created by TotechsStrypper on 10/1/2024 in #help
✅ DbContextOptionsBuilder.UseMongoDB is not referenced after use AspNetCore.HealthChecks.MongoDb
As above I recently added AspNetCore.HealthChecks.MongoDb to my project and the code below stop working
builder.Services.AddDbContext<LightningLanesDbContext>((serviceProvider, opt) =>
{
var databaseSettings = serviceProvider.GetRequiredService<IOptionsMonitor<DatabaseSettings>>().CurrentValue;
//This line
opt.UseMongoDB(databaseSettings.ConnectionString, databaseSettings.Name);
});
builder.Services.AddDbContext<LightningLanesDbContext>((serviceProvider, opt) =>
{
var databaseSettings = serviceProvider.GetRequiredService<IOptionsMonitor<DatabaseSettings>>().CurrentValue;
//This line
opt.UseMongoDB(databaseSettings.ConnectionString, databaseSettings.Name);
});
What i'm currently using (Without the package AspNetCore.HealthChecks.MongoDb)
<PackageReference Include="MongoDB.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" />
<PackageReference Include="MongoDB.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" />
Error
C:\Users\Strypper\source\repos\TotechsThunder\src\LightningLanes\API\Program.cs(50,5): error CS0012: The type 'IMongoClient' is defined in an assembly that is not referenced. You must add a reference to assembly 'MongoDB.Driver, Version=2.25.0.0, Culture=neutral, PublicKeyToken=null'.

Build failed with 1 error(s) and 16 warning(s) in 4,0s
C:\Users\Strypper\source\repos\TotechsThunder\src\LightningLanes\API\Program.cs(50,5): error CS0012: The type 'IMongoClient' is defined in an assembly that is not referenced. You must add a reference to assembly 'MongoDB.Driver, Version=2.25.0.0, Culture=neutral, PublicKeyToken=null'.

Build failed with 1 error(s) and 16 warning(s) in 4,0s
14 replies
CC#
Created by TotechsStrypper on 9/21/2024 in #help
How find file in Docker?
This is my Dockerfile:
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /app
EXPOSE 80

COPY TotechsThunder.sln TotechsThunder.sln
COPY mock/programminglanguages/programminglanguage.js mock/programminglanguages/programminglanguage.js

RUN dotnet restore TotechsThunder.sln

COPY src/Technologies src/Technologies
COPY src/Contracts src/Contracts
WORKDIR /app/src/Technologies
RUN dotnet publish -c Release -o /app/src/out

FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build /app/src/out .
ENTRYPOINT [ "dotnet", "Technologies.dll" ]
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /app
EXPOSE 80

COPY TotechsThunder.sln TotechsThunder.sln
COPY mock/programminglanguages/programminglanguage.js mock/programminglanguages/programminglanguage.js

RUN dotnet restore TotechsThunder.sln

COPY src/Technologies src/Technologies
COPY src/Contracts src/Contracts
WORKDIR /app/src/Technologies
RUN dotnet publish -c Release -o /app/src/out

FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build /app/src/out .
ENTRYPOINT [ "dotnet", "Technologies.dll" ]
I’m having trouble with the programminglanguage.js file. This file contains master data, which my ASP.NET Core app uses during initialization to seed data into the database migration. Everything works fine in my development environment, but when I run the project in a Docker environment, the file can't be found. When I run docker compose build, the service builds successfully. However, when the project runs in Docker, I encounter the following error:
2024-09-21 04:40:15 Unhandled exception. System.IO.FileNotFoundException: Could not find file '/app/..\..\..\..\..\mock\programminglanguages\programminglanguage.js'
2024-09-21 04:40:15 Unhandled exception. System.IO.FileNotFoundException: Could not find file '/app/..\..\..\..\..\mock\programminglanguages\programminglanguage.js'
Here’s the code I’m using to read the file for seeding during migration:
string baseDir = AppDomain.CurrentDomain.BaseDirectory;
string relativePath = @"..\..\..\..\..\mock\programminglanguages\programminglanguage.js";
string fullPath = Path.GetFullPath(Path.Combine(baseDir, relativePath));
string baseDir = AppDomain.CurrentDomain.BaseDirectory;
string relativePath = @"..\..\..\..\..\mock\programminglanguages\programminglanguage.js";
string fullPath = Path.GetFullPath(Path.Combine(baseDir, relativePath));
In Docker, the issue seems to stem from the relative file path not being resolved correctly. I’d appreciate any help in resolving this so the app can find the file in the Docker environment.
8 replies
CC#
Created by TotechsStrypper on 5/12/2024 in #help
Dealing with collection type in MongoDb provider efcore
I recently tried out the new provider for EF Core (MongoDb) The model I got
[Collection("ProgrammingLanguages")]
public class ProgrammingLanguage : BaseEntity
{
public string Name { get; set; } = string.Empty;
public string Logo { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public string? URL { get; set; }
public DateTime ReleaseDate { get; set; }

public ICollection<ProgrammingLanguageVersion>? Versions { get; set; }
}
[Collection("ProgrammingLanguages")]
public class ProgrammingLanguage : BaseEntity
{
public string Name { get; set; } = string.Empty;
public string Logo { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public string? URL { get; set; }
public DateTime ReleaseDate { get; set; }

public ICollection<ProgrammingLanguageVersion>? Versions { get; set; }
}
public class ProgrammingLanguageVersion
{
public string? URL { get; set; }
public DateTime ReleaseDate { get; set; }
}
public class ProgrammingLanguageVersion
{
public string? URL { get; set; }
public DateTime ReleaseDate { get; set; }
}
When I insert the programming language with the versions list mongodb add the new document just fine
//Insert code

context.ProgrammingLanguages.Add(new ProgrammingLanguage()
{
Name = "Test Programming Lang 2",
Versions = new List<ProgrammingLanguageVersion>()
{
new()
{
ReleaseDate = DateTime.Now,
URL = "bruh"
}
}
});

context.ChangeTracker.DetectChanges();
Console.WriteLine(context.ChangeTracker.DebugView.LongView);
await context.SaveChangesAsync();
//Insert code

context.ProgrammingLanguages.Add(new ProgrammingLanguage()
{
Name = "Test Programming Lang 2",
Versions = new List<ProgrammingLanguageVersion>()
{
new()
{
ReleaseDate = DateTime.Now,
URL = "bruh"
}
}
});

context.ChangeTracker.DetectChanges();
Console.WriteLine(context.ChangeTracker.DebugView.LongView);
await context.SaveChangesAsync();
But when I try to retrieve data from the database
var result = context.ProgrammingLanguages;
var result = context.ProgrammingLanguages;
there's an exception below
3 replies
CC#
Created by TotechsStrypper on 3/21/2024 in #help
How does discord read game activities on windows?
Can we achieve this by using WINUI3? And are there any open source projects out there that could achieve the same functionality?
10 replies
CC#
Created by TotechsStrypper on 11/27/2023 in #help
Blazor net 8 InteractiveServer mode problem
I have .net 8 blazor app that enable the following
@rendermode InteractiveServer
@attribute [StreamRendering]
@rendermode InteractiveServer
@attribute [StreamRendering]
When I run the app localhost the all the button interactions are responds just fine, When I deploy the app to azure, Some button work some don't especially this one with the logic
private async Task CopyToClipboard(string text)
{
await ClipboardService.SetTextAsync(text);
ToastService.ShowToast(ToastIntent.Success, "Copied to clipboard");
}
private async Task CopyToClipboard(string text)
{
await ClipboardService.SetTextAsync(text);
ToastService.ShowToast(ToastIntent.Success, "Copied to clipboard");
}
1 replies
CC#
Created by TotechsStrypper on 11/19/2023 in #help
Can't fire click blazor ui button
@page "/members"
@namespace Blazor.Web
@attribute [StreamRendering]

<PageTitle>Members</PageTitle>

<h1>Members</h1>

@if (Users == null)
{
<p><em>Loading...</em></p>
}
else
{
<FluentCard>
<FluentDataGrid Id="membersgrid" Items=@Users GridTemplateColumns="2fr 0.7fr 0.6fr 0.9fr 0.8fr 1.2fr 1fr 1fr 1fr 1.4fr 1.4fr 1.8fr" TGridItem=User>
<PropertyColumn Title="Movie in" Property="@(c => c!.CreatedAt.ToString("dd/MM/yy"))" Sortable="true" Align=Align.Start/>
<TemplateColumn Title="Actions" Align=Align.Center>
<FluentStack>
<FluentButton IconStart="@(new Icons.Regular.Size24.Eye())" Appearance="Appearance.Outline" @onclick=@(() => OpenMemberPaymentRecord(context)) />
<FluentButton IconStart="@(new Icons.Regular.Size24.Edit())" Appearance="Appearance.Outline" @onclick=@(() => {})/>
<FluentButton IconStart="@(new Icons.Regular.Size24.Delete())" Appearance="Appearance.Outline" @onclick=@(() => {})/>
</FluentStack>
</TemplateColumn>
</FluentDataGrid>
</FluentCard>
}
</FluentStack>
@page "/members"
@namespace Blazor.Web
@attribute [StreamRendering]

<PageTitle>Members</PageTitle>

<h1>Members</h1>

@if (Users == null)
{
<p><em>Loading...</em></p>
}
else
{
<FluentCard>
<FluentDataGrid Id="membersgrid" Items=@Users GridTemplateColumns="2fr 0.7fr 0.6fr 0.9fr 0.8fr 1.2fr 1fr 1fr 1fr 1.4fr 1.4fr 1.8fr" TGridItem=User>
<PropertyColumn Title="Movie in" Property="@(c => c!.CreatedAt.ToString("dd/MM/yy"))" Sortable="true" Align=Align.Start/>
<TemplateColumn Title="Actions" Align=Align.Center>
<FluentStack>
<FluentButton IconStart="@(new Icons.Regular.Size24.Eye())" Appearance="Appearance.Outline" @onclick=@(() => OpenMemberPaymentRecord(context)) />
<FluentButton IconStart="@(new Icons.Regular.Size24.Edit())" Appearance="Appearance.Outline" @onclick=@(() => {})/>
<FluentButton IconStart="@(new Icons.Regular.Size24.Delete())" Appearance="Appearance.Outline" @onclick=@(() => {})/>
</FluentStack>
</TemplateColumn>
</FluentDataGrid>
</FluentCard>
}
</FluentStack>
private async Task OpenMemberPaymentRecord(User userInfo)
{
await DialogService.ShowDialogAsync<MemberPaymentRecord>(userInfo, new DialogParameters()
{
Title = $"Hello {userInfo.FirstName}",
OnDialogResult = EventCallback.Factory.Create<DialogResult>(this, result => HandleDialog(result)),
PrimaryAction = "Yes",
PrimaryActionEnabled = false,
SecondaryAction = "No",
Width = "500px",
Height = "500px",
TrapFocus = true,
Modal = true,
});
}
private async Task OpenMemberPaymentRecord(User userInfo)
{
await DialogService.ShowDialogAsync<MemberPaymentRecord>(userInfo, new DialogParameters()
{
Title = $"Hello {userInfo.FirstName}",
OnDialogResult = EventCallback.Factory.Create<DialogResult>(this, result => HandleDialog(result)),
PrimaryAction = "Yes",
PrimaryActionEnabled = false,
SecondaryAction = "No",
Width = "500px",
Height = "500px",
TrapFocus = true,
Modal = true,
});
}
I put a breakpoint in the OpenMemberPaymentRecord but not thing thru
3 replies
CC#
Created by TotechsStrypper on 11/18/2023 in #help
Can't read property in code behind
No description
2 replies
CC#
Created by TotechsStrypper on 11/9/2023 in #help
❔ UWP NavigationCacheMode enable cause app to crash
Our team is currently developing a Proof of Concept (PoC) application that requires the use of NavigationCacheMode.Enabled. This is to maintain the scroll position of the list from the previous page and for connected animation purposes. However, we are encountering an issue where the application crashes upon navigation, returning the following exception message: Link repository: https://github.com/Strypper/Petaverse Branch: master Page that crash: FosterCenterPage.xaml Steps to reproduce 1. Navigate to any of the FosterCenter in the Home page 2. Inside foster center page select a member 3. When successfully navigated to the member page please press the back button to navigate back to the foster center page 4. Application navigate back to foster page and then crash with the below Exception and stack trace Exception
One or more errors occurred. (The object has been closed.

The given object has already been closed / disposed and may no longer be used.)
One or more errors occurred. (The object has been closed.

The given object has already been closed / disposed and may no longer be used.)
Stack trace
at System.Threading.CancellationTokenSource.ExecuteCallbackHandlers(Boolean throwOnFirstException)
at Microsoft.Toolkit.Uwp.UI.Animations.AnimationSet.StartAsync(UIElement element)
at Microsoft.Toolkit.Uwp.UI.Animations.AnimationSet.<Start>d__16.MoveNext()
at System.Threading.WinRTSynchronizationContextBase.Invoker.InvokeCore()
at System.Threading.CancellationTokenSource.ExecuteCallbackHandlers(Boolean throwOnFirstException)
at Microsoft.Toolkit.Uwp.UI.Animations.AnimationSet.StartAsync(UIElement element)
at Microsoft.Toolkit.Uwp.UI.Animations.AnimationSet.<Start>d__16.MoveNext()
at System.Threading.WinRTSynchronizationContextBase.Invoker.InvokeCore()
2 replies
CC#
Created by TotechsStrypper on 11/7/2023 in #help
❔ Where's my database?
No description
2 replies
CC#
Created by TotechsStrypper on 10/22/2023 in #help
❔ Style auto apply to all target controls
I recently created this xaml style, I don't why UWP apply that thing to all the navigation view I only use it when I set the Style property to StoreNavigationViewStyle what going on? The style
xmlns:local="using:Microsoft.UI.Xaml.Controls"
<Style x:Key="StoreNavigationViewStyle" TargetType="local:NavigationView">
xmlns:local="using:Microsoft.UI.Xaml.Controls"
<Style x:Key="StoreNavigationViewStyle" TargetType="local:NavigationView">
The control got affected
<local:NavigationView
Grid.Column="1"
Margin="0,10,10,0"
Padding="0,0,0,15"
VerticalAlignment="Stretch"
ui:Effects.Shadow="{StaticResource PetGalleryPivotShadow}"
IsBackButtonVisible="Collapsed"
IsSettingsVisible="False"
PaneDisplayMode="LeftCompact">
<local:NavigationView
Grid.Column="1"
Margin="0,10,10,0"
Padding="0,0,0,15"
VerticalAlignment="Stretch"
ui:Effects.Shadow="{StaticResource PetGalleryPivotShadow}"
IsBackButtonVisible="Collapsed"
IsSettingsVisible="False"
PaneDisplayMode="LeftCompact">
2 replies
CC#
Created by TotechsStrypper on 8/16/2023 in #help
❔ Amazon SP API
Anyone have use the "papi" before? I don't usually use people's open api so I don't know how to authenticate thru the process to make some request
2 replies
CC#
Created by TotechsStrypper on 8/2/2023 in #help
❔ Create new project in folder
21 replies
CC#
Created by TotechsStrypper on 7/23/2023 in #help
❔ Microsoft.AspNetCore.Http.Features deprecated how to use IFormFileCollection?
I'm at .NET 7 but Microsoft.AspNetCore.Http.Features is deprecated how to use IFormFileCollection now?
34 replies
CC#
Created by TotechsStrypper on 5/23/2023 in #help
❔ Service layer design
This is my interface
using OneOf;
namespace petaverseapi;
public interface IAnimalService
{
#region [ READS ]
Task<IEnumerable<AnimalDTO>> FindAll(string consumerName, CancellationToken cancellationToken = default!);
Task<AnimalDTO?> FindById(int id, string consumerName, CancellationToken cancellationToken = default!);
Task<OneOf<IEnumerable<AnimalDTO>, ServiceError>> FindAllByUserGuid(string userGuid, string consumerName, CancellationToken cancellationToken = default!);
#endregion

#region [ MUTATES ]
Task<OneOf<ServiceSuccess, ServiceError>> Create(CreatePetDTO dto, string consumerName, CancellationToken cancellationToken = default!);
Task<OneOf<ServiceSuccess, ServiceError>> UploadAnimalMultiplePhotosAsync(int animalId, MediaTypeDTO mediaType, IFormFileCollection medias, string consumerName, CancellationToken cancellationToken = default!);


Task<OneOf<ServiceSuccess, ServiceError>> UploadAnimalAvatarPhotoAsync(int animalId, IFormFile avatar, MediaTypeDTO type, string consumerName, CancellationToken cancellationToken = default!);
Task<OneOf<ServiceSuccess, ServiceError>> UploadAnimalPhotoAsync(int animalId, IFormFile file, MediaTypeDTO type, string consumerName, CancellationToken cancellationToken = default!);
Task<OneOf<ServiceSuccess, ServiceError>> Delete(int id, string consumerName, CancellationToken cancellationToken = default!);
#endregion

}
using OneOf;
namespace petaverseapi;
public interface IAnimalService
{
#region [ READS ]
Task<IEnumerable<AnimalDTO>> FindAll(string consumerName, CancellationToken cancellationToken = default!);
Task<AnimalDTO?> FindById(int id, string consumerName, CancellationToken cancellationToken = default!);
Task<OneOf<IEnumerable<AnimalDTO>, ServiceError>> FindAllByUserGuid(string userGuid, string consumerName, CancellationToken cancellationToken = default!);
#endregion

#region [ MUTATES ]
Task<OneOf<ServiceSuccess, ServiceError>> Create(CreatePetDTO dto, string consumerName, CancellationToken cancellationToken = default!);
Task<OneOf<ServiceSuccess, ServiceError>> UploadAnimalMultiplePhotosAsync(int animalId, MediaTypeDTO mediaType, IFormFileCollection medias, string consumerName, CancellationToken cancellationToken = default!);


Task<OneOf<ServiceSuccess, ServiceError>> UploadAnimalAvatarPhotoAsync(int animalId, IFormFile avatar, MediaTypeDTO type, string consumerName, CancellationToken cancellationToken = default!);
Task<OneOf<ServiceSuccess, ServiceError>> UploadAnimalPhotoAsync(int animalId, IFormFile file, MediaTypeDTO type, string consumerName, CancellationToken cancellationToken = default!);
Task<OneOf<ServiceSuccess, ServiceError>> Delete(int id, string consumerName, CancellationToken cancellationToken = default!);
#endregion

}
and here are my the ServiceSuccess and ServiceError basically they are just return information.
namespace petaverseapi;

public record ServiceSuccess(string ServiceName = "",
string MethodName = "",
string ConsumerName = "",
object? AttachedData = default!) : PetaverseSuccess;
namespace petaverseapi;

public record ServiceSuccess(string ServiceName = "",
string MethodName = "",
string ConsumerName = "",
object? AttachedData = default!) : PetaverseSuccess;
namespace petaverseapi;
public record ServiceError(string ServiceName = "", string MethodName = "", string ConsumerName = "") : PetaverseError;
namespace petaverseapi;
public record ServiceError(string ServiceName = "", string MethodName = "", string ConsumerName = "") : PetaverseError;
My question is for FindAll, FindById and FindAllByUserGuid should I return the same a the rest as OneOf<ServiceSuccess, ServiceError> and attached the data in ?
8 replies
CC#
Created by TotechsStrypper on 4/7/2023 in #help
❔ Inheritance or object references ? which one is more meaningful
public class PetService : BaseEntity
{
public string Name { get; set; } = string.Empty;
public string? Image { get; set; }
public string Description { get; set; } = string.Empty;
}
public class PetService : BaseEntity
{
public string Name { get; set; } = string.Empty;
public string? Image { get; set; }
public string Description { get; set; } = string.Empty;
}
My clinic should be like this:
public class ClinicService : BaseEntity
{
public PetService PetService { get; set; } = default!;
public decimal Price { get; set; }
}
public class ClinicService : BaseEntity
{
public PetService PetService { get; set; } = default!;
public decimal Price { get; set; }
}
or
public class ClinicService : PetService
{
public decimal Price { get; set; }
}
public class ClinicService : PetService
{
public decimal Price { get; set; }
}
14 replies
CC#
Created by TotechsStrypper on 3/25/2023 in #help
❔ Fluent Validator: User service inside rule to compare then execute validation
2 replies
CC#
Created by TotechsStrypper on 3/16/2023 in #help
❔ Help: Github action release file not found
3 replies
CC#
Created by TotechsStrypper on 3/1/2023 in #help
❔ EFCORE DESIGN ONE TO MANY
8 replies
CC#
Created by TotechsStrypper on 2/23/2023 in #help
❔ Easy way to make a controller not visible in swagger ui
7 replies