summaryrefslogtreecommitdiff
path: root/Project-Unite/Models/Group.cs
blob: 3ecf2f30ad7b61a98f0093178b98264fa9e33b97 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Project_Unite.Models
{
    public class GroupViewModel
    {
        public List<SelectListItem> Publicities
        {
            get
            {
                return new List<SelectListItem>
                {
                    new SelectListItem { Value="public", Text="Public"},
                    new SelectListItem { Value="publici", Text="Public (Invite Only)"},
                    new SelectListItem { Value="private", Text="Private"},
                    new SelectListItem { Value="privatei", Text="Private (Invite Only)" }
                };
            }
        }

        [Required]
        [MaxLength(25, ErrorMessage = "Your group's name must have a maximum of 25 characters in it.")]
        [MinLength(5, ErrorMessage = "You must set a name with at least 5 characters in it.")]
        public string Name { get; set; }

        [Required]
        public string Publicity { get; set; }

        [Required]
        [MaxLength(6, ErrorMessage = "Hexadecimal color values can only have 6 or less digits.")]
        [MinLength(3, ErrorMessage = "Hexadecimal color values must have at least 3 digits.")]
        public string BannerColorHex { get; set; }

        [Required]
        [AllowHtml]
        public string Description { get; set; }

        [Required]
        [MaxLength(4, ErrorMessage = "Your Short Name can only have 4 characters. Think of it like an acronym.")]
        public string ShortName { get; set; }

    }


    public class Group
    {
        [Required]
        public string Id { get; set; }

        [Required]
        [MaxLength(25, ErrorMessage ="Your group's name must have a maximum of 25 characters in it.")]
        [MinLength(5, ErrorMessage ="You must set a name with at least 5 characters in it.")]
        public string Name { get; set; }

        [Required]
        public int Publicity { get; set; }

        [Required]
        [MaxLength(6, ErrorMessage ="Hexadecimal color values can only have 6 or less digits.")]
        [MinLength(3, ErrorMessage ="Hexadecimal color values must have at least 3 digits.")]
        public string BannerColorHex { get; set; }

        [Required]
        [AllowHtml]
        public string Description { get; set; }

        [Required]
        [MaxLength(4, ErrorMessage ="Your Short Name can only have 4 characters. Think of it like an acronym.")]
        public string ShortName { get; set; }

        [Required]
        public double RawReputation { get; set; }

        public ApplicationUser[] Users
        {
            get
            {
                var db = new ApplicationDbContext();
                return db.Users.Where(x => x.GroupId == this.Id).ToArray();
            }
        }

        public int Reputation
        {
            get
            {
                return ((int)Math.Round(RawReputation));
            }
        }

    }
}