public async Task <JsonResult> CreatePostsByAdvertiser(AnunciosDTO posts) { Result <WrapperSimpleTypesDTO> result = new Result <WrapperSimpleTypesDTO>(); try { AnunciantesServices advertiserService = new AnunciantesServices(); posts.CodigoAnunciante = UserLoggedIn().PersonaDelUsuario.AnuncianteDeLaPersona.Consecutivo; posts.CodigoIdiomaUsuarioBase = UserLoggedIn().PersonaDelUsuario.CodigoIdioma; if (posts.Consecutivo != 0) { posts.AnunciosPaises.ToList().ForEach(c => c.CodigoAnuncio = posts.Consecutivo); posts.CategoriasAnuncios.ToList().ForEach(c => c.CodigoAnuncio = posts.Consecutivo); result.obj = await advertiserService.ModificarAnuncio(posts); } else { result.obj = await advertiserService.CrearAnuncio(posts); } if (result.obj == null) { return(Json(Helper.returnErrorSaveObj(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet)); } return(Json(Helper.returnSuccessObj(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet)); } catch (Exception) { return(Json(Helper.returnErrorSaveObj(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet)); } }
public async Task AnunciantesServices_CrearAnuncio_ShouldCreate() { AnunciantesServices anuncianteServices = new AnunciantesServices(); AnunciosDTO anuncios = new AnunciosDTO { CodigoAnunciante = 1, Vencimiento = new DateTime(2020, 1, 1), NumeroApariciones = 1000, CodigoArchivo = 11, UrlPublicidad = "hollaaaa", AnunciosContenidos = new List <AnunciosContenidosDTO> { new AnunciosContenidosDTO { Titulo = "holaa", CodigoIdioma = 1 }, new AnunciosContenidosDTO { Titulo = "hi", CodigoIdioma = 2 } }, AnunciosPaises = new List <AnunciosPaisesDTO> { new AnunciosPaisesDTO { CodigoPais = 1 } }, CategoriasAnuncios = new List <CategoriasAnunciosDTO> { new CategoriasAnunciosDTO { CodigoCategoria = 3 } } }; WrapperSimpleTypesDTO wrapper = await anuncianteServices.CrearAnuncio(anuncios); Assert.IsNotNull(wrapper); Assert.IsTrue(wrapper.Exitoso); }