TotechsStrypper
TotechsStrypper
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
CC#
Created by TotechsStrypper on 2/20/2023 in #help
❔ Services collection life time
Hi guys, is it possible to register some services later when the application up and running ? I stuck into a scenario like this I have WPF or MAUI application that use signalR for realtime communication, the problem is the application requirement doesn't want to force users to login to connect to the signalR hub, they can do it later. And this is where the problem happen, if you register signalR when you boot up the app it will lack all the information about that user needed to connect to the hub because many scenarios users don't want to login first but they can do that when they want to This question is not about SignalR it's about the life time of registering services to ServiceCollection.
17 replies
CC#
Created by TotechsStrypper on 2/19/2023 in #help
❔ Cassandra: which programming language have the best support for accessing and write data?
Hi my application need to scale the data source, we heard about Cassandra and really want to use it, does anyone know which programming language best support this database like EF Core for SQL Server ? so we can create a webapp accessing it and deploy it to Azure function
5 replies
CC#
Created by TotechsStrypper on 2/18/2023 in #help
❔ Unit test: The source 'IQueryable' doesn't implement 'IAsyncEnumerable<T>'
My test keep failing when it trying to get to this line of code
var foods = await _foodRepository.FindAll().ToListAsync(cancellationToken);
var foods = await _foodRepository.FindAll().ToListAsync(cancellationToken);
Detail FindAll
IQueryable<T> FindAll(Expression<Func<T, bool>>? predicate = null);
IQueryable<T> FindAll(Expression<Func<T, bool>>? predicate = null);
Controller
public async Task<IActionResult> GetAll(CancellationToken cancellationToken = default)
{
var foods = await _foodRepository.FindAll().ToListAsync(cancellationToken);
return Ok(_mapper.Map<IEnumerable<FoodDTO>>(foods));
}
public async Task<IActionResult> GetAll(CancellationToken cancellationToken = default)
{
var foods = await _foodRepository.FindAll().ToListAsync(cancellationToken);
return Ok(_mapper.Map<IEnumerable<FoodDTO>>(foods));
}
Test
public async Task FoodController_GetAll_ReturnOk()
{
#region[Arrange]
var foods = A.Fake<IEnumerable<Food>>();
var foodsDTO = A.Fake<IEnumerable<FoodDTO>>();
A.CallTo(() => _mapper.Map<IEnumerable<FoodDTO>>(foods)).Returns(foodsDTO);
var controller = new FoodController(_mapper, _foodRepository, _userFoodRepository);
#endregion

#region[Act]
var result = await controller.GetAll();
#endregion

#region[Assert]
result.Should().NotBeNull();
result.Should().BeOfType(typeof(OkObjectResult));
#endregion
}
public async Task FoodController_GetAll_ReturnOk()
{
#region[Arrange]
var foods = A.Fake<IEnumerable<Food>>();
var foodsDTO = A.Fake<IEnumerable<FoodDTO>>();
A.CallTo(() => _mapper.Map<IEnumerable<FoodDTO>>(foods)).Returns(foodsDTO);
var controller = new FoodController(_mapper, _foodRepository, _userFoodRepository);
#endregion

#region[Act]
var result = await controller.GetAll();
#endregion

#region[Assert]
result.Should().NotBeNull();
result.Should().BeOfType(typeof(OkObjectResult));
#endregion
}
36 replies