Example #1
0
        public void deleteVice(Vice vice)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.CommandText = "EXEC delete_vice " + vice.Id;
            cmd.Connection  = dbHelper.connection;
            cmd.ExecuteNonQuery();
        }
Example #2
0
        public void setVice(Vice vice)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.CommandText = "EXEC set_vice " + vice.Id + ", " + vice.EmployeeNumber + ", " + vice.Organisation.Id + ", '" + vice.Surname + "', '" + vice.Prename + "'";
            cmd.Connection  = dbHelper.connection;
            cmd.ExecuteNonQuery();
        }
Example #3
0
        public Vice newVice(Vice vice)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.CommandText = "EXEC new_vice " + vice.EmployeeNumber + ", " + vice.Organisation.Id + ", '" + vice.Surname + "', '" + vice.Prename + "'";
            cmd.Connection  = dbHelper.connection;
            SqlDataReader reader = cmd.ExecuteReader();

            reader.Read();
            vice.Id = Convert.ToInt32(reader["ID"]);
            return(vice);
        }
Example #4
0
        public async Task CreateAsync(CreateViceInputModel input, string userId)
        {
            var vice = new Vice()
            {
                AddedByUserId = userId,
                CategoryId    = input.CategoryId,
                Content       = input.Content,
            };

            await this.vicesRepository.AddAsync(vice);

            await this.vicesRepository.SaveChangesAsync();
        }
Example #5
0
        public Vice getVice(int id)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.CommandText = "EXEC get_vice " + id;
            cmd.Connection  = dbHelper.connection;
            SqlDataReader reader = cmd.ExecuteReader();

            reader.Read();
            Vice vice = mapVice(reader);

            reader.Close();
            return(vice);
        }
Example #6
0
 /// <summary>
 /// Extension method to get the string associated to a Vice
 /// </summary>
 /// <param name="vice">The vice</param>
 /// <returns>The vice as a readable string</returns>
 public static string GetString(this Vice vice)
 {
     string[] vices =
     {
         "Lager",          "Cider",        "Ale",
         "Moonshine",      "Red Wine",     "Whiskey",
         "Martini",        "Jägerbomb",    "Tequila",
         "Joint",          "Stout",        "Margarita",
         "Gin & Tonic",    "Bloody Mary",  "Screwdriver",
         "Saké",           "Mead",         "White Wine",
         "Cigar",          "Varian Cigar", "Porter",
         "Energy Drink",   "Painkillers",  "Mojito",
         "Bourbon & Cola", "Beer",         "Spliff",
         "Stimulants",     "Absinthe",     "Rum",
         "Champagne",      "Vape Pen",     "Sherry",
         "Espresso",       "Water",        "Rubbing Alcohol",
         "Hot Wings",      "Antacids",     "Smokes",
         "Vodka",          "Maria",        "Super Antacids",
         "Indigo's Reserve"
     };
     return(vices[(int)vice]);
 }
Example #7
0
 /// <summary>
 /// Check if a number is equal to the vice
 /// </summary>
 /// <param name="vice">The vice</param>
 /// <param name="nb">The number</param>
 /// <returns>true if equals, false otherwise</returns>
 public static bool IsEqual(this Vice vice, int nb)
 {
     return(vice == (Vice)nb);
 }