예제 #1
0
        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));
            }
        }
예제 #2
0
        public async Task <JsonResult> SaveAdvertiser(AnunciantesDTO advertiser)
        {
            Result <AnunciantesDTO> result = new Result <AnunciantesDTO>();

            try
            {
                AnunciantesServices advertiserService = new AnunciantesServices();
                advertiser.Personas.Usuarios     = UserLoggedIn();
                advertiser.Personas.TipoPerfil   = advertiser.Personas.Usuarios.TipoPerfil;
                advertiser.Personas.CodigoIdioma = advertiser.Personas.Usuarios.PersonaDelUsuario.CodigoIdioma;
                WrapperSimpleTypesDTO res = new WrapperSimpleTypesDTO();
                if (advertiser.Consecutivo != 0)
                {
                    PersonasServices personService = new PersonasServices();
                    res = await personService.ModificarPersona(advertiser.Personas);

                    if (res != null)
                    {
                        res = await advertiserService.ModificarInformacionAnunciante(advertiser);

                        result.obj = advertiser;
                    }
                }
                else
                {
                    advertiser.Anuncios = null;
                    advertiser.Personas.Usuarios.Personas          = null;
                    advertiser.Personas.Usuarios.PersonaDelUsuario = null;
                    res = await advertiserService.CrearAnunciante(advertiser);

                    if (res != null)
                    {
                        advertiser.Consecutivo            = (int)res.ConsecutivoCreado;
                        advertiser.CodigoPersona          = res.ConsecutivoPersonaCreado;
                        advertiser.Personas.CodigoUsuario = res.ConsecutivoUsuarioCreado;
                        result.obj = advertiser;
                        AuthenticateServices AuthenticateService = new AuthenticateServices();
                        var newUser = await AuthenticateService.VerificarUsuario(UserLoggedIn());

                        setUserLogin(newUser);
                    }
                }

                if (res == null)
                {
                    return(Json(Helper.returnErrorObj(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet));
                }

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(Helper.returnErrorObj(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet));
            }
        }
        public async Task AnunciantesServices_BuscaAnuncioPaisPorConsecutivo_ShouldList()
        {
            AnunciantesServices anuncianteServices = new AnunciantesServices();

            AnunciosDTO anuncio = new AnunciosDTO
            {
                Consecutivo = 3
            };

            AnunciosDTO anuncioBuscado = await anuncianteServices.BuscarAnuncioPorConsecutivo(anuncio);

            Assert.IsNotNull(anuncioBuscado);
        }
        public async Task AnuncianteServices_EliminarAnuncio_ShouldDelete()
        {
            AnunciantesServices anuncianteServices = new AnunciantesServices();

            AnunciosDTO anuncioParaBorrar = new AnunciosDTO
            {
                Consecutivo = 7
            };

            WrapperSimpleTypesDTO wrapper = await anuncianteServices.EliminarAnuncio(anuncioParaBorrar);

            Assert.IsNotNull(wrapper);
            Assert.IsTrue(wrapper.Exitoso);
        }
        public async Task AnunciantesServices_ListarAnunciosDeUnAnunciante_ShouldList()
        {
            AnunciantesServices anuncianteServices = new AnunciantesServices();

            AnunciosDTO anuncio = new AnunciosDTO
            {
                SkipIndexBase           = 0,
                TakeIndexBase           = 20,
                CodigoAnunciante        = 1,
                CodigoIdiomaUsuarioBase = 1
            };

            List <AnunciosDTO> lstAnuncios = await anuncianteServices.ListarAnunciosDeUnAnunciante(anuncio);

            Assert.IsNotNull(lstAnuncios);
            Assert.IsTrue(lstAnuncios.Count > 0);
            Assert.IsTrue(lstAnuncios.TrueForAll(x => x.Anunciantes == null));
            Assert.IsTrue(lstAnuncios.TrueForAll(x => x.Archivos == null));
        }
        public async Task AnunciantesServices_ListarAnunciosPaisesDeUnAnuncio_ShouldList()
        {
            AnunciantesServices anuncianteServices = new AnunciantesServices();

            AnunciosPaisesDTO anuncio = new AnunciosPaisesDTO
            {
                CodigoAnuncio = 2
            };

            List <AnunciosPaisesDTO> lstAnunciosPaises = await anuncianteServices.ListarAnunciosPaisesDeUnAnuncio(anuncio);

            Assert.IsNotNull(lstAnunciosPaises);
            Assert.IsTrue(lstAnunciosPaises.Count > 0);
            Assert.IsTrue(lstAnunciosPaises.TrueForAll(x => x.Anuncios == null));
            Assert.IsTrue(lstAnunciosPaises.TrueForAll(x => x.Paises.Idiomas == null));
            Assert.IsTrue(lstAnunciosPaises.TrueForAll(x => x.Paises.Monedas == null));
            Assert.IsTrue(lstAnunciosPaises.TrueForAll(x => x.Paises.AnunciosPaises.Count == 0));
            Assert.IsTrue(lstAnunciosPaises.TrueForAll(x => x.Paises.GruposEventos.Count == 0));
            Assert.IsTrue(lstAnunciosPaises.TrueForAll(x => x.Paises.Personas.Count == 0));
        }
예제 #7
0
        public async Task <JsonResult> DeletePostsByAdvertiser(AnunciosDTO ad)
        {
            Result <WrapperSimpleTypesDTO> result = new Result <WrapperSimpleTypesDTO>();

            try
            {
                AnunciantesServices advertiserService = new AnunciantesServices();
                result.obj = await advertiserService.EliminarAnuncio(new AnunciosDTO { Consecutivo = ad.Consecutivo });

                if (result.obj == null)
                {
                    return(Json(Helper.returnErrorDelete(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet));
                }

                return(Json(Helper.returnSuccessDeleteObj(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(Helper.returnErrorDelete(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);
        }
예제 #9
0
        public async Task <JsonResult> GetProfile()
        {
            Result <AnunciantesDTO> result = new Result <AnunciantesDTO>();

            try
            {
                AnunciantesServices categoryService = new AnunciantesServices();
                AnunciantesDTO      advertiser      = new AnunciantesDTO();
                advertiser.CodigoPersona = UserLoggedIn().PersonaDelUsuario.Consecutivo;
                result.obj = await categoryService.BuscarAnunciantePorCodigoPersona(advertiser);

                if (result.obj == null)
                {
                    return(Json(Helper.returnErrorObj(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet));
                }

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(Helper.returnErrorObj(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet));
            }
        }
예제 #10
0
        public async Task <JsonResult> UpdateCounterAdSeen(AnunciosDTO ad)
        {
            Result <WrapperSimpleTypesDTO> result = new Result <WrapperSimpleTypesDTO>();

            try
            {
                AnunciantesServices advertiserService = new AnunciantesServices();
                result.obj = await advertiserService.AumentarContadorClickDeUnAnuncio(ad);

                if (result.obj != null)
                {
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(Helper.returnErrorSaveObj(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception)
            {
                return(Json(Helper.returnErrorSaveObj(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet));
            }
        }
예제 #11
0
        public async Task <JsonResult> GetPostsByAdvertiser(AnunciosDTO posts)
        {
            Result <AnunciosDTO> result = new Result <AnunciosDTO>();

            try
            {
                AnunciantesServices advertiserService = new AnunciantesServices();
                AnunciosDTO         postToSearch      = new AnunciosDTO();
                postToSearch.Consecutivo = posts.Consecutivo;

                result.obj = await advertiserService.BuscarAnuncioPorConsecutivo(postToSearch);

                if (result.obj == null)
                {
                    return(Json(Helper.returnErrorObj(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet));
                }

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(Helper.returnErrorObj(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet));
            }
        }
예제 #12
0
        public async Task <JsonResult> GetListPostsByAdvertiser(AnunciosDTO posts)
        {
            Result <AnunciosDTO> result = new Result <AnunciosDTO>();

            try
            {
                AnunciantesServices categoryService = new AnunciantesServices();
                var ass = UserLoggedIn();
                posts.CodigoAnunciante        = UserLoggedIn().PersonaDelUsuario.AnuncianteDeLaPersona.Consecutivo;
                posts.CodigoIdiomaUsuarioBase = UserLoggedIn().PersonaDelUsuario.CodigoIdioma;
                result.list = await categoryService.ListarAnunciosDeUnAnunciante(posts);

                if (result.list == null)
                {
                    return(Json(Helper.returnErrorList(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet));
                }

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(Helper.returnErrorList(UserLoggedIn().PersonaDelUsuario.CodigoIdioma), JsonRequestBehavior.AllowGet));
            }
        }
 public NoticiasPageModel()
 {
     _noticiasServices    = new NoticiasServices();
     _anunciantesServices = new AnunciantesServices();
     _dateTimeHelper      = FreshIOC.Container.Resolve <IDateTimeHelper>();
 }