Skip to content

Commit

Permalink
Add DataAnnotations to models #52
Browse files Browse the repository at this point in the history
Add DataAnnotations to models #52
  • Loading branch information
grantcolley committed Jun 11, 2022
1 parent afd1615 commit 21d3821
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 20 deletions.
44 changes: 40 additions & 4 deletions src/Headway.RemediatR.Core/Model/Customer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Headway.RemediatR.Core.Enums;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace Headway.RemediatR.Core.Model
{
Expand All @@ -11,21 +12,56 @@ public Customer()
}

public int CustomerId { get; set; }
public AccountStatus AccountStatus { get; set; }
public List<Product>? Products { get; set; }

[Required(ErrorMessage = "Title is required")]
[StringLength(5, ErrorMessage = "Title cannot exceed 5 characters")]
public string? Title { get; set; }

[Required(ErrorMessage = "Firstname is required")]
[StringLength(50, ErrorMessage = "Firstname cannot exceed 50 characters")]
public string? FirstName { get; set; }

[Required(ErrorMessage = "Surname is required")]
[StringLength(50, ErrorMessage = "Surname cannot exceed 50 characters")]
public string? Surname { get; set; }

[StringLength(15, ErrorMessage = "Telephone cannot exceed 50 characters")]
public string? Telephone { get; set; }

[StringLength(50, ErrorMessage = "Email cannot exceed 50 characters")]
public string? Email { get; set; }

[StringLength(50, ErrorMessage = "Address Line 1 cannot exceed 50 characters")]
public string? Address1 { get; set; }

[StringLength(50, ErrorMessage = "Address Line 2 cannot exceed 50 characters")]
public string? Address2 { get; set; }

[StringLength(50, ErrorMessage = "Address Line 3 cannot exceed 50 characters")]
public string? Address3 { get; set; }

[StringLength(50, ErrorMessage = "Address Line 4 cannot exceed 50 characters")]
public string? Address4 { get; set; }

[StringLength(50, ErrorMessage = "Address Line 5 cannot exceed 50 characters")]
public string? Address5 { get; set; }

[Required(ErrorMessage = "Country is required")]
[StringLength(50, ErrorMessage = "Country cannot exceed 50 characters")]
public string? Country { get; set; }

[Required(ErrorMessage = "Post Code is required")]
[StringLength(10, ErrorMessage = "Post Code cannot exceed 10 characters")]
public string? PostCode { get; set; }
public int? SortCode { get; set; }
public int? AccountNumber { get; set; }
public AccountStatus AccountStatus { get; set; }
public List<Product>? Products { get; set; }

[MaxLength(8)]
[RegularExpression(@"^(\d){2}-(\d){2}-(\d){2}$", ErrorMessage = "Sort Code must be 3 sets of 2 digits, separated by hyphens e.g. 12-34-56")]
public string? SortCode { get; set; }

[MaxLength(8)]
[RegularExpression(@"^(\d){8}$", ErrorMessage = "AccountNumber must be 8 digits")]
public string? AccountNumber { get; set; }
}
}
19 changes: 15 additions & 4 deletions src/Headway.RemediatR.Core/Model/Product.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Headway.RemediatR.Core.Model
{
public class Product
{
public int ProductId { get; set; }
public string? Name { get; set; }
public ProductType ProductType { get; set; }
public RateType RateType { get; set; }
public RepaymentType RepaymentType { get; set; }
public DateTime StartDate { get; set; }
public decimal Value { get; set; }
public int Duration { get; set; }
public decimal Rate { get; set; }

[Required(ErrorMessage = "Name is required")]
[StringLength(50, ErrorMessage = "Name cannot exceed 50 characters")]
public string? Name { get; set; }

[Column(TypeName = "decimal(18, 2)")]
public decimal? Value { get; set; }

[Range(3, 360, ErrorMessage = "Duration must be between 3 and 360")]
public int? Duration { get; set; }

[Column(TypeName = "decimal(4, 2)")]
public decimal? Rate { get; set; }
}
}
15 changes: 12 additions & 3 deletions src/Headway.RemediatR.Core/Model/Program.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Headway.RemediatR.Core.Model
{
public class Program
{
public int ProgramId { get; set; }
public string? Name { get; set; }
public decimal? Compensation { get; set; }
public decimal? CompensatoryInterest { get; set; }
public ProductType ProductType { get; set; }
public RateType RateType { get; set; }
public RepaymentType RepaymentType { get; set; }
public DateTime? StartDate { get; set; }
public DateTime? EndDate { get; set; }

[Required(ErrorMessage = "Name is required")]
[StringLength(50, ErrorMessage = "Name cannot exceed 50 characters")]
public string? Name { get; set; }

[Column(TypeName = "decimal(18, 2)")]
public decimal? Compensation { get; set; }

[Column(TypeName = "decimal(4, 2)")]
public decimal? CompensatoryInterest { get; set; }
}
}
80 changes: 71 additions & 9 deletions src/Headway.RemediatR.Core/Model/Redress.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace Headway.RemediatR.Core.Model
{
Expand All @@ -16,28 +17,89 @@ public Redress()
public List<RedressProduct>? RedressProducts { get; set; }
public RefundCalculation? RefundCalculation { get; set; }
public RefundCalculation? RefundVerification { get; set; }
public DateTime? CreatedDate { get; set; }

[MaxLength(50)]
public string? RedressCaseOwner { get; set; }
public string? RefundReview { get; set; }

[MaxLength(50)]
public string? RedressLoadBy { get; set; }
public DateTime? RedressLoadDate { get; set; }

[MaxLength(50)]
public string? RefundReviewStatus { get; set; }

[StringLength(250, ErrorMessage = "Refund Review Comment cannot exceed 250 characters")]
public string? RefundReviewComment { get; set; }

[MaxLength(50)]
public string? RefundReviewBy { get; set; }
public DateTime? RefundReviewDate { get; set; }
public string? RefundReviewComment { get; set; }
public string? RedressReview { get; set; }

[MaxLength(50)]
public string? RedressReviewStatus { get; set; }

[StringLength(250, ErrorMessage = "Redress Review Comment cannot exceed 250 characters")]
public string? RedressReviewComment { get; set; }

[MaxLength(50)]
public string? RedressReviewBy { get; set; }
public DateTime? RedressReviewDate { get; set; }
public string? RedressReviewComment { get; set; }
public string? RedressValidation { get; set; }

[MaxLength(50)]
public string? RedressValidationStatus { get; set; }

[StringLength(250, ErrorMessage = "Redress Validation Comment cannot exceed 250 characters")]
public string? RedressValidationComment { get; set; }

[MaxLength(50)]
public string? RedressValidationBy { get; set; }
public DateTime? RedressValidationDate { get; set; }

[MaxLength(50)]
public string? CommunicationGenerationStatus { get; set; }

[MaxLength(50)]
public string? CommunicationGenerationBy { get; set; }
public DateTime? CommunicationGenerationDate { get; set; }

[MaxLength(50)]
public string? CommunicationDispatchStatus { get; set; }

[StringLength(250, ErrorMessage = "Communication Dispatch Comment cannot exceed 250 characters")]
public string? CommunicationDispatchComment { get; set; }

[MaxLength(50)]
public string? CommunicationDispatchBy { get; set; }
public DateTime? CommunicationDispatchDate { get; set; }

public bool? ResponseRequired { get; set; }
public bool? ResponseRecieved { get; set; }
public string? AwaitingResponse { get; set; }

[MaxLength(50)]
public string? AwaitingResponseStatus { get; set; }

[StringLength(250, ErrorMessage = "Awaiting Response Comment cannot exceed 250 characters")]
public string? AwaitingResponseComment { get; set; }

[MaxLength(50)]
public string? AwaitingResponseBy { get; set; }
public DateTime? AwaitingResponseDate { get; set; }

[MaxLength(50)]
public string? PaymentGenerationStatus { get; set; }

[MaxLength(50)]
public string? PaymentGenerationBy { get; set; }
public DateTime? PaymentGenerationDate { get; set; }
public string? FinalRedressReview { get; set; }

[MaxLength(50)]
public string? FinalRedressReviewStatus { get; set; }

[StringLength(250, ErrorMessage = "Final Redress Review Comment cannot exceed 250 characters")]
public string? FinalRedressReviewComment { get; set; }

[MaxLength(50)]
public string? FinalRedressReviewBy { get; set; }
public DateTime? FinalRedressReviewDate { get; set; }
public string? FinalRedressReviewComment { get; set; }
}
}
15 changes: 15 additions & 0 deletions src/Headway.RemediatR.Core/Model/RefundCalculation.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Headway.RemediatR.Core.Model
{
public class RefundCalculation
{
public int RefundCalculationId { get; set; }

[Column(TypeName = "decimal(18, 2)")]
public decimal? BasicRefundAmount { get; set; }

[Column(TypeName = "decimal(18, 2)")]
public decimal? CompensatoryAmount { get; set; }

[Column(TypeName = "decimal(18, 2)")]
public decimal? CompensatoryInterestAmount { get; set; }

[Column(TypeName = "decimal(18, 2)")]
public decimal? TotalCompensatoryAmount { get; set; }

[Column(TypeName = "decimal(18, 2)")]
public decimal? TotalRefundAmount { get; set; }

public DateTime? CalculatedDate { get; set; }

[MaxLength(50)]
public string? CalculatedBy { get; set; }
}
}

0 comments on commit 21d3821

Please sign in to comment.