Exemplo n.º 1
0
        public static List <Festival> FromUsers(int UserID)
        {
            List <Festival> festivals = new List <Festival>();
            var             query     = Sql.Query($"SELECT * FROM Festival WHERE OwnerID = {UserID};");

            while (query.Read())
            {
                Festival result = new Festival
                {
                    EventID      = query.GetInt32(0),
                    EventName    = query.GetString(1),
                    StartDate    = query.GetDateTime(2),
                    EndDate      = query.GetDateTime(3),
                    EntryPrice   = query.GetDecimal(4),
                    YoutubeVideo = query.GetValue(5).ToString(),
                    Image        = query.GetValue(6).ToString(),
                    Info         = query.GetValue(7)?.ToString(),
                    Location     = query.GetString(8),
                    Clicks       = query.GetInt32(9),
                    Draft        = query.GetBoolean(10),
                    OwnerID      = query.GetInt32(11)
                };
                festivals.Add(result);
            }
            return(festivals);
        }
Exemplo n.º 2
0
        public static Festival Read(int ID)
        {
            var query = Sql.Query($"SELECT * FROM Festival WHERE FestivalID = {ID};");

            query.Read();
            if (query.HasRows)
            {
                Festival result = new Festival();
                result.EventID      = query.GetInt32(0);
                result.EventName    = query.GetString(1);
                result.StartDate    = query.GetDateTime(2);
                result.EndDate      = query.GetDateTime(3);
                result.EntryPrice   = query.GetDecimal(4);
                result.YoutubeVideo = query.GetValue(5).ToString();
                result.Image        = query.GetValue(6).ToString();
                result.Info         = query.GetValue(7)?.ToString();
                result.Location     = query.GetString(8);
                result.Clicks       = query.GetInt32(9);
                result.Draft        = query.GetBoolean(10);
                result.OwnerID      = query.GetInt32(11);

                return(result);
            }
            else
            {
                throw new NullReferenceException("Could not found " + ID);
            }
        }