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

Trello exercise #4

Open
wants to merge 2 commits into
base: master
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
6 changes: 6 additions & 0 deletions FakeTrello/FakeTrello.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,14 @@
<DependentUpon>Global.asax</DependentUpon>
</Compile>
<Compile Include="Models\AccountViewModels.cs" />
<Compile Include="Models\Board.cs" />
<Compile Include="Models\Card.cs" />
<Compile Include="Models\CardList.cs" />
<Compile Include="Models\CardUserAndCreator.cs" />
<Compile Include="Models\IdentityModels.cs" />
<Compile Include="Models\List.cs" />
<Compile Include="Models\ManageViewModels.cs" />
<Compile Include="Models\TrelloUser.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Startup.cs" />
</ItemGroup>
Expand Down
20 changes: 20 additions & 0 deletions FakeTrello/Models/Board.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;

namespace FakeTrello.Models
{
public class Board
{
[Key]
public int BoardId { get; set; }

public string Name { get; set; }

public string URL { get; set; }

public List<List> Lists { get; set; }
}
}
18 changes: 18 additions & 0 deletions FakeTrello/Models/Card.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;

namespace FakeTrello.Models
{
public class Card
{
[Key]
public int CardId { get; set; }

public string Title { get; set; }

public string Description { get; set; }
}
}
14 changes: 14 additions & 0 deletions FakeTrello/Models/CardList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace FakeTrello.Models
{
public class CardList
{

Choose a reason for hiding this comment

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

If the intention for this class is to represent the one-to-many relationship between Lists and Cards, you don't need to make a class to represent a join table in SQL. Entity Framework will create the join table without this class with just the List in your List class.

public int CardId { get; set; }

public int ListId { get; set; }
}
}
14 changes: 14 additions & 0 deletions FakeTrello/Models/CardUserAndCreator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace FakeTrello.Models

Choose a reason for hiding this comment

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

just like my note above, you don't need to create this class for the join table. Entity Framework will create the table based on the navigation property in your Trello User class.

{
public class CardUserAndCreator
{
public int TrelloUserId { get; set; }

public int CardCreatorID { get; set; }
}
}
18 changes: 18 additions & 0 deletions FakeTrello/Models/List.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;

namespace FakeTrello.Models
{
public class List
{
[Key]
public int ListId { get; set; }

public string Name { get; set; }

public List<Card> Cards { get; set; }
}
}
35 changes: 35 additions & 0 deletions FakeTrello/Models/TrelloUser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;

// Entity is our Object Relational Mapper (ORM)

namespace FakeTrello.Models
{
public class TrelloUser
{
[Key]
public int TrelloUserId { get; set; } // Primary Key (not nullible; must be unique)

// Stacking of properties applies multiple annotations
// to the following property
[MinLength(10)]
[MaxLength(60)]
public string Email { get; set; }

[MaxLength(60)]
public string Username { get; set; }

[MaxLength(60)]
public string FullName { get; set; }

[MaxLength(60)]
public string PasswordHash { get; set; }

public ApplicationUser BaseUser { get; set; } // 1 to 1 relationship

public List<Board> Boards { get; set; } // 1 to many (boards) relationship
}
}
Binary file added FakeTrelloBoardERD.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@

### Fake Trello ERD

[ERD goes here]
![ERD](FakeTrelloBoardERD.PNG)