Exemplo n.º 1
0
        public async Task ModifyAlert(string name, int time, int?day, string text, List <ulong> roles, ulong channel)
        {
            var alert = await _plogDbContext.Alerts.Where(x => x.Name == name).FirstOrDefaultAsync();

            var timeInfo = await _timeZoneService.GetTime(alert.DiscordUserId, day, time);

            alert.Time        = timeInfo.Item2;
            alert.Day         = timeInfo.Item1;
            alert.Description = text;
            alert.Roles       = roles.ConcatenateULongs();
            alert.ChannelId   = channel;
            _plogDbContext.Update(alert);
            await _plogDbContext.SaveChangesAsync();
        }
Exemplo n.º 2
0
        public async Task SaveTimeZonePreference(string abbreviation, ulong discordUserId)
        {
            var timePref = await _plogDbContext.Times.FirstOrDefaultAsync(t => t.DiscordUserId == discordUserId);

            if (timePref == null)
            {
                timePref = new TimeZonePreference
                {
                    DiscordUserId = discordUserId,
                    TimeZone      = abbreviation
                };
                _plogDbContext.Add(timePref);
            }
            else
            {
                timePref.TimeZone = abbreviation;
                _plogDbContext.Update(timePref);
            }

            await _plogDbContext.SaveChangesAsync();
        }