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 multiple description #674

Merged
merged 3 commits into from
Jun 20, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public void Configure(EntityTypeBuilder<Workshop> builder)
builder.HasMany(x => x.Teachers)
.WithOne(x => x.Workshop)
.HasForeignKey(x => x.WorkshopId);
builder.HasMany(x => x.WorkshopDescriptionItems)
.WithOne(x => x.Workshop)
.HasForeignKey(x => x.WorkshopId);
}
}
}
4 changes: 1 addition & 3 deletions OutOfSchool/OutOfSchool.DataAccess/Models/Workshop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ public class Workshop : IKeyedEntity<Guid>, IImageDependentEntity<Workshop>
[Range(0, 10000, ErrorMessage = "Field value should be in a range from 1 to 10 000")]
public decimal Price { get; set; } = default;

[Required(ErrorMessage = "Description is required")]
[MaxLength(500)]
public string Description { get; set; } = string.Empty;
public virtual ICollection<WorkshopDescriptionItem> WorkshopDescriptionItems { get; set; }

public bool WithDisabilityOptions { get; set; } = default;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.ComponentModel.DataAnnotations;

namespace OutOfSchool.Services.Models
{
public class WorkshopDescriptionItem : IKeyedEntity<Guid>
{
public Guid Id { get; set; }

[Required(ErrorMessage = "Description heading is required")]
[MaxLength(200)]
public string SectionName { get; set; }

[Required(ErrorMessage = "Description text is required")]
[MaxLength(2000)]
public string Description { get; set; }

public Guid WorkshopId { get; set; }

public virtual Workshop Workshop { get; set; }
}
}
2 changes: 2 additions & 0 deletions OutOfSchool/OutOfSchool.DataAccess/OutOfSchoolDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ public OutOfSchoolDbContext(DbContextOptions<OutOfSchoolDbContext> options)

public DbSet<ProviderSectionItem> ProviderSectionItems { get; set; }

public DbSet<WorkshopDescriptionItem> WorkshopDescriptionItems { get; set; }

public DbSet<ChangesLog> ChangesLog { get; set; }

public DbSet<ProviderAdminChangesLog> ProviderAdminChangesLog { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class WorkshopES

public OwnershipType ProviderOwnership { get; set; }

public string Description { get; set; }
public string Description { get; set; } // Sum of all WorkshopDescriptionItems (SectionName + Description)

public int MinAge { get; set; }

Expand Down
Loading