Example #1
0
        public async Task <ActionResult <EventModelResponse> > Create(
            EventViewMode eventViewMode,
            CancellationToken cancellationToken = default)
        {
            var @event = new Event(
                eventViewMode.Name,
                eventViewMode.OddsForFirstTeam,
                eventViewMode.OddsForFirstTeam,
                eventViewMode.OddsForSecondTeam,
                eventViewMode.EventStartDate);

            await this.eventRepository.AddAsync(@event);

            var eventResponse = new EventListResponse();
            var result        = await this.eventRepository.SaveChangesAsync();

            var eventModelResponse = this.MapResponseModel(@event);

            if (result == 0)
            {
                eventModelResponse.ErrorMesage = "Ther was an Error";
                eventModelResponse.Succeeded   = false;
            }

            return(this.Ok(eventModelResponse));
        }
Example #2
0
        public override async Task <EventListResponse> GetList(EmptyRequest request, ServerCallContext context)
        {
            var events = await _ctx.Events.ToListAsync();

            var ret = new EventListResponse();

            ret.Events.AddRange(events);
            var file  = File.ReadAllBytes(".\\cover.jpg");
            var data  = Convert.ToBase64String(file);
            var small = ImageUtils.GetSmallBase64(data);

            for (int i = 0; i < 22; i++)
            {
                ret.Events.Add(new Event
                {
                    EventName = $"Unplugged #{i}",
                    CoverData = small,
                    StartTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
                    Type      = EventType.Unplugged,
                    Status    = i < 20 ? EventStatus.Finished : EventStatus.Planning
                });
            }


            return(ret);
        }
Example #3
0
        public async Task <ActionResult <EventListResponse> > List(CancellationToken cancellationToken = default)
        {
            var events = await this.eventRepository.All().Select(e => new EventViewMode()
            {
                EventStartDate    = e.EventStartDate,
                Id                = e.Id,
                Name              = e.Name,
                OddsForDraw       = e.OddsForDraw,
                OddsForFirstTeam  = e.OddsForFirstTeam,
                OddsForSecondTeam = e.OddsForSecondTeam,
            }).ToListAsync();

            var eventResponse = new EventListResponse()
            {
                Events    = events,
                Succeeded = true,
            };

            return(this.Ok(eventResponse));
        }