Skip to content
This repository has been archived by the owner on Jul 8, 2024. It is now read-only.

FAQ & Home Page #1

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/dotnet-desktop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: build

on:
push:
pull_request:
branches: [main]
paths:
- "**.cs"
- "**.csproj"

env:
DOTNET_VERSION: "8.0.101" # The .NET SDK version to use

jobs:
build:
name: build-${{matrix.os}}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
- uses: actions/checkout@v3
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Install dependencies
run: dotnet restore

- name: Build
run: dotnet build --configuration Release --no-restore

- name: test
run: dotnet test
9 changes: 2 additions & 7 deletions Emulair.BusinessLogic/Emulair.BusinessLogic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@

<ItemGroup>
<PackageReference Include="AutoMapper" Version="12.0.1" />
<PackageReference Include="FluentValidation" Version="11.8.1" />
</ItemGroup>

<ItemGroup>
<Folder Include="Implementation\Games\Mappings\" />
<Folder Include="Implementation\Games\Models\" />
<Folder Include="Implementation\Games\Validations\" />
<PackageReference Include="FluentValidation" Version="11.9.0" />
<PackageReference Include="SpecFlow" Version="3.9.74" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using AutoMapper;
using CollectiHaven.BusinessLogic.Implementation.Account.Models;
using Emulair.Entities;
using EmulairWEB.Models;
using System;
Expand All @@ -12,6 +13,14 @@ public UserProfile()
CreateMap<RegisterModel, User>()
.ForMember(a => a.UserId, a => a.MapFrom(s => Guid.NewGuid()))
.ForMember(a => a.PasswordHash, a => a.MapFrom(s => s.Password));

CreateMap<User, UserModel>()
.ForMember(a => a.Id, a => a.MapFrom(s => s.UserId))
.ForMember(a => a.RegistrationDay, a => a.MapFrom(s => s.RegistrationDate))
.ForMember(a => a.Email, a => a.MapFrom(s => s.Email))
.ForMember(a => a.Role, a => a.MapFrom(s => s.Role))
.ForMember(a => a.FirstName, a => a.MapFrom(s => s.FirstName))
.ForMember(a => a.LastName, a => a.MapFrom(s => s.LastName));
}
}
}
22 changes: 22 additions & 0 deletions Emulair.BusinessLogic/Implementation/Account/Models/UserModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.ComponentModel.DataAnnotations;

namespace CollectiHaven.BusinessLogic.Implementation.Account.Models
{
public class UserModel
{
public Guid Id { get; set; }
[Required(ErrorMessage = "Please enter the Mail.")]
public string Email { get; set; }
[Required(ErrorMessage = "Please enter the First Name.")]
public string FirstName { get; set; }
[Required(ErrorMessage = "Please enter the Last Name.")]
public string LastName { get; set; }
[Required(ErrorMessage = "Please enter the Birthdary.")]
public DateTime BirthDay { get; set; }
public DateTime RegistrationDay { get; set; }
public string? ProfileDescription { get; set; }
public decimal Balance { get; set; }
public string Role { get; set; }

}
}
12 changes: 10 additions & 2 deletions Emulair.BusinessLogic/Implementation/Account/UserAccountService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Linq;
using Emulair.BusinessLogic.Base;
using EmulairWEB.Models;
using CollectiHaven.BusinessLogic.Implementation.Account.Models;

namespace Emulair.BusinessLogic.Implementation.Account
{
Expand Down Expand Up @@ -40,12 +41,19 @@ public CurrentUserDto Login(string email, string password)
Email = user.Email,
FirstName = user.FirstName,
LastName = user.LastName,
IsAuthenticated = true
//Roles = user.UserRoles.Select(ur => ur.Role.Name).ToList()
IsAuthenticated = true,
Role = "Admin"
};
return UserNew;
}

public UserModel DisplayProfile()
{
var user = UnitOfWork.Users.Find(CurrentUser.Id);
var userProfile = Mapper.Map<User, UserModel>(user);
return userProfile;
}

public void RegisterNewUser(RegisterModel model)
{
RegisterUserValidator.Validate(model).ThenThrow(model);
Expand Down
60 changes: 60 additions & 0 deletions Emulair.BusinessLogic/Implementation/Game/GameService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using Emulair.BusinessLogic.Base;
using Emulair.BusinessLogic.Implementation.Game.Models;
using EmulairWEB.Models;
using Microsoft.EntityFrameworkCore;

namespace Emulair.BusinessLogic.Implementation.Game
{
public class GameService : BaseService
{
public GameService(ServiceDependencies dependencies) : base(dependencies)
{

}

public List<GameListItem> GetGames()
{
var gameList = new List<GameListItem>();

var userGames = UnitOfWork.UserGames
.Get()
.Where(userGame => userGame.UserId == CurrentUser.Id)
.Include(userGame => userGame.Game)
.OrderByDescending(userGame => userGame.LastPlayed)
.ToList();


if (userGames == null)
{
return gameList;
}

foreach (var userGame in userGames)
{
var gameListItem = Mapper.Map<UserGame, GameListItem>(userGame);



gameListItem.TotalAchievements = UnitOfWork.Achievements
.Get()
.Where(achievement => achievement.GameId == userGame.GameId)
.Count();

gameListItem.TotalAchievementsUnlocked = UnitOfWork.UserAchievements
.Get()
.Where(userAchievement => userAchievement.UserId == CurrentUser.Id
&& userAchievement.GameId == userGame.GameId)
.Where(userAchievement => userAchievement.IsUnlocked == true)
.Count();
var listImages = UnitOfWork.Images
.Where(image => gameListItem.IconId == image.ImageId)
.Select(image => image.Content)
.ToList();
gameListItem.Images = listImages;
gameList.Add(gameListItem);
}

return gameList;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using AutoMapper;
using Emulair.BusinessLogic.Implementation.Game.Models;
using EmulairWEB.Models;

namespace Emulair.BusinessLogic.Implementation.Game.Mappings
{
public class UserGameProfile : Profile
{
public UserGameProfile()
{
CreateMap<UserGame, GameListItem>()
.ForMember(dest => dest.GameId, opt => opt.MapFrom(src => src.GameId))
.ForMember(dest => dest.Title, opt => opt.MapFrom(src => src.Game.Title))
.ForMember(dest => dest.IconId, opt => opt.MapFrom(src => src.Game.IconId))
.ForMember(dest => dest.Description, opt => opt.MapFrom(src => src.Game.Description))
.ForMember(dest => dest.TotalHoursPlayed, opt => opt.MapFrom(src => src.TotalHoursPlayed))
.ForMember(dest => dest.LastPlayed, opt => opt.MapFrom(src => src.LastPlayed));
}
}
}
15 changes: 15 additions & 0 deletions Emulair.BusinessLogic/Implementation/Game/Models/GameListItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Emulair.BusinessLogic.Implementation.Game.Models
{
public class GameListItem
{
public Guid GameId { get; set; }
public string? Title { get; set; }
public string? Description { get; set; }
public int? TotalHoursPlayed { get; set; }
public DateTime? LastPlayed { get; set; }
public Guid IconId { get; set; }
public List<byte[]> Images { get; set; }
public int? TotalAchievements { get; set; }
public int? TotalAchievementsUnlocked { get; set; }
}
}
12 changes: 0 additions & 12 deletions Emulair.BusinessLogic/Implementation/Games/GameService.cs

This file was deleted.

46 changes: 46 additions & 0 deletions Emulair.BusinessLogic/Implementation/News/Mappings/NewsMapper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using AutoMapper;
using Emulair.BusinessLogic.Implementation.News.Models;
using EmulairWEB.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Emulair.BusinessLogic.Implementation.News.Mappings
{
public class NewsMapper : Profile
{
public NewsMapper()
{
CreateMap<News1, NewsModel>()
.ForMember(a => a.NewsId, a => a.MapFrom(s => s.NewsId))
.ForMember(a => a.AuthorId, a => a.MapFrom(s => s.AuthorId))
.ForMember(a => a.Description, a => a.MapFrom(s => s.Description))
.ForMember(a => a.PostDate, a => a.MapFrom(s => s.PostDate))
.ForMember(a => a.Title, a => a.MapFrom(s => s.Title));

CreateMap<News1, EditNewsModel>()
.ForMember(a => a.Description, a => a.MapFrom(s => s.Description))
.ForMember(a => a.Title, a => a.MapFrom(s => s.Title));

CreateMap<EditNewsModel, NewsModel>()
.ForMember(a => a.AuthorId, a => a.Ignore())
.ForMember(a => a.Description, a => a.MapFrom(s => s.Description))
.ForMember(a => a.PostDate, a => a.Ignore())
.ForMember(a => a.Title, a => a.MapFrom(s => s.Title))
.ForMember(a => a.Replies, a => a.Ignore())
.ForMember(a => a.NewComment, a => a.Ignore())
.ForMember(a => a.Comments, a => a.Ignore())
.ForMember(a => a.Images, a => a.Ignore());


CreateMap<NewsModel, News1>()
.ForMember(a => a.NewsId, a => a.MapFrom(s => s.NewsId))
.ForMember(a => a.AuthorId, a => a.MapFrom(s => s.AuthorId))
.ForMember(a => a.Description, a => a.MapFrom(s => s.Description))
.ForMember(a => a.PostDate, a => a.MapFrom(s => s.PostDate))
.ForMember(a => a.Title, a => a.MapFrom(s => s.Title));
}
}
}
15 changes: 15 additions & 0 deletions Emulair.BusinessLogic/Implementation/News/Models/EditNewsModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Emulair.BusinessLogic.Implementation.News.Models
{
public class EditNewsModel
{
public Guid NewsId { get; set; }
public string Title { get; set; }
public string Description { get; set; }
}
}
35 changes: 35 additions & 0 deletions Emulair.BusinessLogic/Implementation/News/Models/NewsModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using EmulairWEB.Models;
using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Emulair.BusinessLogic.Implementation.News.Models
{
public class NewsModel
{
public Guid NewsId { get; set; }
[Required(ErrorMessage = "Please enter the Title.")]
public string Title { get; set; } = null!;
[Required(ErrorMessage = "Please enter the Description.")]
public string Description { get; set; } = null!;
public Guid AuthorId { get; set; }
public string Author { get; set; }

public DateTime PostDate { get; set; }
public List<byte[]> Images { get; set; }
public List<Comment> Comments { get; set; }
public Comment NewComment { get; set; }
public List<Comment> Replies { get; set; }
public List<IFormFile> formFiles { get; set; }
public NewsModel()
{
Images = new List<byte[]>();
Comments = new List<Comment>();
Replies = new List<Comment>();
}
}
}
Loading
Loading