Beispiel #1
0
        public async Task <CreateResult> CreateAsync(CreateEventContract eventContract, string organizerEmail)
        {
            EventModel newEvent = new EventModel
            {
                Name           = eventContract.Name,
                Description    = eventContract.Description,
                UnixTime       = eventContract.UnixTime,
                City           = eventContract.City,
                Longitude      = eventContract.Longitude,
                Latitude       = eventContract.Latitude,
                OrganizerEmail = organizerEmail
            };

            await _context.Events.AddAsync(newEvent);

            await _context.SaveChangesAsync();

            foreach (var tag in eventContract.TagIds)
            {
                await SubscribeAsync(organizerEmail, newEvent.Id, tag);
            }

            return(new CreateResult
            {
                Success = true
            });
        }
        public async Task <IActionResult> Create([FromBody] CreateEventContract eventContract)
        {
            string email        = User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
            var    createResult = await _eventService.CreateAsync(eventContract, email);

            if (!createResult.Success)
            {
                return(BadRequest(new InvalidParameterResponse()));
            }

            return(Ok(new SuccessResponse()));
        }