Created
September 26, 2016 08:57
-
-
Save AndyButland/d56d2c46c69d8ab754e4079a0df9d5b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.ComponentModel.DataAnnotations; | |
public class Category | |
{ | |
private Category() | |
{ | |
} | |
public Category(string name) | |
{ | |
SetName(name); | |
} | |
public int Id { get; set; } | |
[Required] | |
[StringLength(50)] | |
public string Name { get; private set; } | |
public void SetName(string name) | |
{ | |
Name = name; | |
} | |
} | |
public class Task | |
{ | |
private Task() | |
{ | |
} | |
public Task(string description, Category category) | |
{ | |
SetDetails(description, category); | |
} | |
public int Id { get; set; } | |
[Required] | |
[StringLength(500)] | |
public string Description { get; private set; } | |
public bool IsComplete { get; private set; } | |
[Required] | |
public Category Category { get; private set; } | |
public void SetDetails(string description, Category category) | |
{ | |
Description = description; | |
Category = category; | |
} | |
public void MarkComplete() | |
{ | |
IsComplete = true; | |
} | |
public void MarkIncomplete() | |
{ | |
IsComplete = false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment