Skip to content

Commit ccff46d

Browse files
committed
EXAM PREP 01-SEPTEMBER-2018
1 parent a753252 commit ccff46d

36 files changed

+3534
-0
lines changed
Binary file not shown.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.26124.0
5+
MinimumVisualStudioVersion = 15.0.26124.0
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VaporStore", "VaporStore\VaporStore.csproj", "{ED12E334-BE70-4871-974E-392404F6FBE1}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Debug|x64 = Debug|x64
12+
Debug|x86 = Debug|x86
13+
Release|Any CPU = Release|Any CPU
14+
Release|x64 = Release|x64
15+
Release|x86 = Release|x86
16+
EndGlobalSection
17+
GlobalSection(SolutionProperties) = preSolution
18+
HideSolutionNode = FALSE
19+
EndGlobalSection
20+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
21+
{ED12E334-BE70-4871-974E-392404F6FBE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22+
{ED12E334-BE70-4871-974E-392404F6FBE1}.Debug|Any CPU.Build.0 = Debug|Any CPU
23+
{ED12E334-BE70-4871-974E-392404F6FBE1}.Debug|x64.ActiveCfg = Debug|Any CPU
24+
{ED12E334-BE70-4871-974E-392404F6FBE1}.Debug|x64.Build.0 = Debug|Any CPU
25+
{ED12E334-BE70-4871-974E-392404F6FBE1}.Debug|x86.ActiveCfg = Debug|Any CPU
26+
{ED12E334-BE70-4871-974E-392404F6FBE1}.Debug|x86.Build.0 = Debug|Any CPU
27+
{ED12E334-BE70-4871-974E-392404F6FBE1}.Release|Any CPU.ActiveCfg = Release|Any CPU
28+
{ED12E334-BE70-4871-974E-392404F6FBE1}.Release|Any CPU.Build.0 = Release|Any CPU
29+
{ED12E334-BE70-4871-974E-392404F6FBE1}.Release|x64.ActiveCfg = Release|Any CPU
30+
{ED12E334-BE70-4871-974E-392404F6FBE1}.Release|x64.Build.0 = Release|Any CPU
31+
{ED12E334-BE70-4871-974E-392404F6FBE1}.Release|x86.ActiveCfg = Release|Any CPU
32+
{ED12E334-BE70-4871-974E-392404F6FBE1}.Release|x86.Build.0 = Release|Any CPU
33+
EndGlobalSection
34+
EndGlobal
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
namespace VaporStore.Data.Attributes
2+
{
3+
using System.Collections;
4+
using System.ComponentModel.DataAnnotations;
5+
6+
public class AtLeastOneElementAttribute : ValidationAttribute
7+
{
8+
public override bool IsValid(object value)
9+
{
10+
IList collection = value as IList;
11+
if (collection != null)
12+
{
13+
return collection.Count > 0;
14+
}
15+
16+
return false;
17+
}
18+
}
19+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace VaporStore.Data
2+
{
3+
public static class Configuration
4+
{
5+
public static string ConnectionString =
6+
@"Server=.;Database=VaporStore;Trusted_Connection=True";
7+
}
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace VaporStore.Data.Enums
2+
{
3+
public enum CardType
4+
{
5+
Debit,
6+
Credit
7+
}
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace VaporStore.Data.Enums
2+
{
3+
public enum PurchaseType
4+
{
5+
Retail,
6+
Digital
7+
}
8+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
namespace VaporStore.Data.Models
2+
{
3+
using System.Collections.Generic;
4+
using System.ComponentModel.DataAnnotations;
5+
using System.ComponentModel.DataAnnotations.Schema;
6+
using VaporStore.Data.Enums;
7+
8+
public class Card
9+
{
10+
[Key]
11+
public int Id { get; set; }
12+
13+
[Required]
14+
[RegularExpression(@"^[0-9]{4}\s*[0-9]{4}\s*[0-9]{4}\s*[0-9]{4}$")]
15+
public string Number { get; set; }
16+
17+
[Required]
18+
[RegularExpression(@"^[0-9]{3}$")]
19+
public string Cvc { get; set; }
20+
21+
[Required]
22+
public CardType Type { get; set; }
23+
24+
[ForeignKey(nameof(User))]
25+
public int UserId { get; set; }
26+
[Required]
27+
public User User { get; set; }
28+
29+
public ICollection<Purchase> Purchases { get; set; } = new HashSet<Purchase>();
30+
}
31+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
namespace VaporStore.Data.Models
2+
{
3+
using System.Collections.Generic;
4+
using System.ComponentModel.DataAnnotations;
5+
6+
public class Developer
7+
{
8+
[Key]
9+
public int Id { get; set; }
10+
11+
[Required]
12+
public string Name { get; set; }
13+
14+
public ICollection<Game> Games { get; set; } = new HashSet<Game>();
15+
}
16+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
namespace VaporStore.Data.Models
2+
{
3+
using System;
4+
using System.Collections.Generic;
5+
using System.ComponentModel.DataAnnotations;
6+
using System.ComponentModel.DataAnnotations.Schema;
7+
using VaporStore.Data.Attributes;
8+
9+
public class Game
10+
{
11+
[Key]
12+
public int Id { get; set; }
13+
14+
[Required]
15+
public string Name { get; set; }
16+
17+
[Required]
18+
[Range(typeof(decimal), "0", "79228162514264337593543950335")]
19+
public decimal Price { get; set; }
20+
21+
[Required]
22+
public DateTime ReleaseDate { get; set; }
23+
24+
[Required]
25+
[ForeignKey(nameof(Developer))]
26+
public int DeveloperId { get; set; }
27+
public Developer Developer { get; set; }
28+
29+
[Required]
30+
[ForeignKey(nameof(Genre))]
31+
public int GenreId { get; set; }
32+
public Genre Genre { get; set; }
33+
34+
public ICollection<Purchase> Purchases { get; set; } = new HashSet<Purchase>();
35+
36+
[AtLeastOneElement]
37+
public ICollection<GameTag> GameTags { get; set; } = new HashSet<GameTag>();
38+
}
39+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace VaporStore.Data.Models
2+
{
3+
using System.ComponentModel.DataAnnotations;
4+
5+
public class GameTag
6+
{
7+
public int GameId { get; set; }
8+
[Required]
9+
public Game Game { get; set; }
10+
11+
public int TagId { get; set; }
12+
[Required]
13+
public Tag Tag { get; set; }
14+
}
15+
}

0 commit comments

Comments
 (0)