Example #1
0
        public async Task <IActionResult> AddNewEvent([FromBody, Required] CreateEventRequestModel model)
        {
            if (model == null)
            {
                return(new BadRequestObjectResult(new ResponseModel
                {
                    Status = false,
                    Message = APIMessages.NO_ARGUMENTS_MESSAGE
                }));
            }

            // Get the location's description
            var geoLoc = await Geocoding.Geocode(apiKey, model.LocationString);

            // Add the new event
            dbContext.Events.Add(new Event
            {
                Id       = Guid.NewGuid(),
                Location = geoLoc,
                Radius   = 10,
                Type     = model.Type
            });

            // Save changes to SQL
            dbContext.SaveChanges();

            return(new OkObjectResult(new ResponseModel
            {
                Status = true,
                Message = APIMessages.OK_MESSAGE
            }));
        }
        public async Task <ActionResult> Create(CreateEventRequestModel model)
        {
            string userId = this.User.GetId();

            int id = await this.eventService.Create(model.Name, model.Sport, model.Location, model.DateTime, model.Positions, model.IsSportEvent, userId);

            return(Created(nameof(this.Create), id));
        }
Example #3
0
        public async Task <IActionResult> Create(CreateEventRequestModel model)
        {
            var managerId = this.currentUser.GetId();

            var id = await this.eventService.CreateAsync(
                model.Name,
                model.ImageUrl,
                model.Venue,
                model.PhoneNumber,
                model.Email,
                model.ConductDate,
                model.Description,
                model.Price,
                managerId);

            return(this.Created(nameof(this.Create), id));
        }