/// <summary> /// Guarda las entradas con videos de youtube /// </summary> /// <param name="youtubeDto"></param> /// <returns></returns> public ApiCallResult GuardarEntradaYoutube(EntradaYoutubeDto youtubeDto) { try { #region Validaciones Blogs slug = this.repository.ObtenerSlug(youtubeDto.Slug); if (slug != null) { throw new NegocioExecption($"Ya existe ha sido creado previamente un post con este SLUG {youtubeDto.Slug}", 202); } BusquedaDto titulo = this.blogService.BuscarPost(youtubeDto.Titulo).FirstOrDefault(); if (!string.IsNullOrEmpty(titulo.Slug)) { throw new NegocioExecption($"Ya existe ha sido creado previamente un post con este Titulo {youtubeDto.Titulo}", 202); } UsuarioDto usuario = this.usuarioService.VerificarUsuario(youtubeDto.Creador); if (usuario is null) { throw new NegocioExecption($"Error de logeo con {youtubeDto.Creador}", 401); } #endregion using (TransactionScope scope = new TransactionScope()) { #region Guardar Entrada youtubeDto.IdVideo = this.GuardarRutaYoutube(youtubeDto.Rutavideo); youtubeDto.Tipo = "YO"; youtubeDto.Estado = true; youtubeDto.Fechacreacion = DateTime.Now; youtubeDto.Idcreador = usuario.Idusuario; Blogs blog = mapper.Map <Blogs>(youtubeDto); this.repository.GuardarPost(blog); #endregion #region Guardar Keywords Blogs blogCreado = this.repository.ObtenerSlug(youtubeDto.Slug); this.blogService.GuardarKeyWords(youtubeDto.KeyWords, blogCreado.Idblog); #endregion scope.Complete(); } return(new ApiCallResult { Estado = true, Mensaje = "Video guardado correctamente" }); } catch (NegocioExecption) { throw; } catch (Exception) { throw; } }
public IActionResult GuardarEntradaYoutube(EntradaYoutubeDto youtubeDto) { try { ApiCallResult result = this.service.GuardarEntradaYoutube(youtubeDto); return(StatusCode((int)System.Net.HttpStatusCode.OK, result)); } catch (NegocioExecption e) { return(StatusCode((int)System.Net.HttpStatusCode.NotFound, e.Message)); } catch (Exception e) { return(StatusCode((int)System.Net.HttpStatusCode.InternalServerError, e.Message)); } }