Ejemplo n.º 1
0
        public async Task <IHttpActionResult> Add(CompetitionRequestModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            try
            {
                var competition = new Competition
                {
                    Title       = model.Title,
                    Type        = model.Type,
                    Date        = model.Date,
                    Location    = model.Location,
                    Description = model.Description
                };

                var result = await competitionWriteService.AddAsync(competition);

                return(Ok(result));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Ejemplo n.º 2
0
        public async Task <IHttpActionResult> Update(CompetitionRequestModel model)
        {
            try
            {
                var competition = await competitionReadService.GetByIdAsync(model.Id);

                competition.Title       = model.Title;
                competition.Type        = model.Type;
                competition.Date        = model.Date;
                competition.Location    = model.Location;
                competition.Description = model.Description;

                await competitionWriteService.UpdateAsync(competition);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }