public async Task <IActionResult> Put(int redeSocialId, RedeSocialDto model)
        {
            try
            {
                var redeSocial = await _repository.GetByIdAsync(redeSocialId);

                if (redeSocial == null)
                {
                    return(NotFound());
                }

                _mapper.Map(model, redeSocial);

                _repository.Update(redeSocial);
                if (await _repository.SaveChanges())
                {
                    return(Created($"/api/redeSocial/{model.Id}", _mapper.Map <RedeSocialDto>(model)));
                }
            }
            catch (System.Exception ex)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Banco de dados falhou {ex.Message}"));
            }
            return(BadRequest());
        }
        public async Task AddRedeSocial(int Id, RedeSocialDto model, bool isEvento)
        {
            try
            {
                var RedeSocial = _mapper.Map <RedeSocial>(model);
                if (isEvento)
                {
                    RedeSocial.EventoId      = Id;
                    RedeSocial.PalestranteId = null;
                }
                else
                {
                    RedeSocial.EventoId      = null;
                    RedeSocial.PalestranteId = Id;
                }

                _redeSocialPersist.Add <RedeSocial>(RedeSocial);

                await _redeSocialPersist.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
 public async Task <IActionResult> Post(RedeSocialDto model)
 {
     try
     {
         var redeSocial = _mapper.Map <RedeSocial>(model);
         _repository.Add(redeSocial);
         if (await _repository.SaveChanges())
         {
             return(Created($"/api/redeSocial/{redeSocial.Id}", _mapper.Map <RedeSocialDto>(redeSocial)));
         }
     }
     catch (System.Exception ex)
     {
         return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Banco de dados falhou {ex.Message}"));
     }
     return(BadRequest());
 }