Outline

Exercise: Creating Custom Models

In order to build out the Api Endpoints we'll need some Custom Models in place before we start.

In the Conduit.Models project, add the following models to the Responses namespace:

Add the Comment Class with the following properties
Visibility | Type         | Name
------------------------------------------------------------------
  public   | int          | Id
  public   | DateTime     | CreatedAt
  public   | DateTime     | UpdatedAt
  public   | string       | Body
  public   | UserProfile  | Author

Initialize the Author Property in the constructor.

Add the Article Class with the following properties
Visibility | Type         | Name
------------------------------------------------------------------
  public   | string       | Slug
  public   | string       | Title
  public   | string       | Description
  public   | string       | Body
  public   | string[]     | TagList
  public   | DateTime     | CreatedAt
  public   | DateTime     | UpdatedAt
  public   | bool         | Favorited
  public   | int          | FavoritesCount
  public   | UserProfile  | Author

In the Conduit.Models project, add the following models to the Requests namespace:

Add the Generic ArticleRequest<T> Class with the following properties
Visibility | Type         | Name
------------------------------------------------------------------
  public   | T            | Article

This is a Generic Class. We created a Generic for UserRequest.

Hint: Review UserRequest.cs

Add the ArticleCreateRequest Class with the following properties
Visibility | Type     | Name        | Rules                      | Error Message
---------------------------------------------------------------------------------------------------
  public   | string   | Title       | Required, StringLenth(50)  | Title max character length is 50.
  public   | string   | Description | Required, StringLenth(50)  | Title max character length is 50.
  public   | string   | Body        | Required, StringLenth(200) | Body max character length is 200.
  public   | string[] | TagList

Hint: Review Login.cs or Register.cs

Add the ArticleUpdateRequest Class with the following properties
Visibility | Type     | Name        | Rules                      | Error Message
---------------------------------------------------------------------------------------------------
  public   | string   | Title       | Required, StringLenth(50)  | Title max character length is 50.
  public   | string   | Description | Required, StringLenth(50)  | Title max character length is 50.
  public   | string   | Body        | Required, StringLenth(200) | Body max character length is 200.
Add the Generic CommentRequest<T> Class with the following properties
Visibility | Type         | Name
------------------------------------------------------------------
  public   | T            | Comment
Add the CommentAddRequest Class with the following properties
Visibility | Type     | Name        | Rules                      | Error Message
---------------------------------------------------------------------------------------------------
  public   | string   | Body        | Required, StringLenth(200) | Body max character length is 200.
 

I finished! On to the next chapter