Skip to content

Commit

Permalink
#5 Add view models for teams.
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Fürschuß committed Nov 23, 2016
1 parent b98df19 commit c13a9e7
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Wuzlstats/ViewModels/Teams/IndexViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.Collections.Generic;

namespace Wuzlstats.ViewModels.Teams
{
public class IndexViewModel
{
public string ActiveFilter { get; set; }
public bool Recent { get; set; }
public int Days { get; set; }
public IEnumerable<TeamViewModel> Teams { get; set; }
}
}
11 changes: 11 additions & 0 deletions src/Wuzlstats/ViewModels/Teams/PlayerViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;

namespace Wuzlstats.ViewModels.Teams
{
public class PlayerViewModel
{
public int Id { get; set; }
public string Name { get; set; }
public string Image { get; set; }
}
}
30 changes: 30 additions & 0 deletions src/Wuzlstats/ViewModels/Teams/TeamViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;

namespace Wuzlstats.ViewModels.Teams
{
public class TeamViewModel
{
public PlayerViewModel Player1 { get; set; }
public PlayerViewModel Player2 { get; set; }
public int Wins { get; set; }
public int Losses { get; set; }
public DateTime LastGamePlayedOn { get; set; }
public int GamesCount { get; set; }

// ReSharper disable once PossibleLossOfFraction
public double Rank => Losses == 0 ? Wins : (Wins == 0 ? 0.1d / Losses : (double)Wins / Losses);

public bool Equals(PlayerViewModel p1, PlayerViewModel p2)
{
if (Player1 == null || Player2 == null)
{
return false;
}
if (p1.Id <= p2.Id)
{
return Player1.Id == p1.Id && Player2.Id == p2.Id;
}
return Player2.Id == p1.Id && Player1.Id == p2.Id;
}
}
}

0 comments on commit c13a9e7

Please sign in to comment.