Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add artist entity to movie library #77

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
46 changes: 46 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -296,3 +296,49 @@ jobs:
INDEX_LIST=$(seq 0 ${MAX_INDEX}) # generate the list of indexes
INDEX_JSON=$(jq --null-input --compact-output '. |= [inputs]' <<< ${INDEX_LIST}) # convert the list to the json
echo "json=${INDEX_JSON}" >> $GITHUB_OUTPUT # save the json to the GITHUB_OUTPUT environment variable

lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4.2.2

- name: Setup .NET
uses: actions/setup-dotnet@v4.0.1
with:
dotnet-version: '6.0.x'

- name: Install .NET Code Analyzer
run: dotnet tool install --global dotnet-format

- name: Run .NET Code Analyzer
run: dotnet format --check
env:
PATH: ${{ runner.tool_cache }}/.dotnet/tools:$PATH

static-analysis:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4.2.2

- name: Setup .NET
uses: actions/setup-dotnet@v4.0.1
with:
dotnet-version: '6.0.x'

- name: Install SonarScanner
run: dotnet tool install --global dotnet-sonarscanner

- name: Run SonarScanner
run: dotnet sonarscanner begin /k:"${{ github.repository }}" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="${{ secrets.SONAR_HOST_URL }}"
env:
PATH: ${{ runner.tool_cache }}/.dotnet/tools:$PATH

- name: Build solution
run: dotnet build RazorPagesMovie.sln

- name: End SonarScanner
run: dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
env:
PATH: ${{ runner.tool_cache }}/.dotnet/tools:$PATH
11 changes: 10 additions & 1 deletion src/Data/RazorPagesMovieContext.cs
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ public RazorPagesMovieContext(DbContextOptions<RazorPagesMovieContext> options)

public DbSet<Movie> Movie { get; set; } = default!;
public DbSet<User> Users { get; set; } = default!;
public DbSet<Artist> Artists { get; set; } = default!;

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
@@ -42,6 +43,14 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
entity.Property(m => m.Timestamp).HasDefaultValue(new byte[8]); // Set default value for Timestamp
});

// Artist configuration
modelBuilder.Entity<Artist>(entity =>
Copy link
Preview

Copilot AI Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate Artist configuration block detected. Remove this redundant configuration to avoid potential conflicts, as the Artist entity is already configured earlier.

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

{
entity.Property(a => a.Name).IsRequired().HasMaxLength(100);
entity.Property(a => a.Bio).HasMaxLength(1000);
entity.Property(a => a.Timestamp).IsConcurrencyToken();
});

// Seed data with hashed passwords
var hashedAdminPw = HashPassword("password");
var hashedUserPw = HashPassword("password");
@@ -109,4 +118,4 @@ private static string HashPassword(string password)
return $"{Convert.ToBase64String(salt)}:{hashed}";
}
}
}
}
23 changes: 23 additions & 0 deletions src/Models/Artist.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace RazorPagesMovie.Models
{
public class Artist
{
public int Id { get; set; }

[Required]
[StringLength(100)]
public string Name { get; set; } = string.Empty;

[StringLength(1000)]
public string Bio { get; set; } = string.Empty;

[Timestamp]
public byte[] Timestamp { get; set; } = new byte[8];

public virtual ICollection<Movie> Movies { get; set; } = new List<Movie>();
}
}