예제 #1
0
        public async Task <IActionResult> Create([Bind("IdAnuncio,IdModelo,ValorCompra,ValorVenda,DataVenda")] Anuncio anuncio)
        {
            if (ModelState.IsValid)
            {
                _context.Add(anuncio);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdModelo"] = new SelectList(_context.Modelo, "IdModelo", "Descricao", anuncio.IdModelo);
            return(View(anuncio));
        }
예제 #2
0
        public AtualizarAnuncioResponse AtualizarAnuncio(AtualizarAnuncioRequest atualizarAnuncioRequest)
        {
            Anuncio anuncio = new Anuncio();

            anuncio = atualizarAnuncioRequest.Anuncio;

            AtualizarAnuncioResponse atualizarAnuncioResponse = new AtualizarAnuncioResponse();

            atualizarAnuncioResponse.Successo = _servicoAnuncio.Atualizar(anuncio);

            return(atualizarAnuncioResponse);
        }
예제 #3
0
 public ActionResult Edit([FromBody] Anuncio item)
 {
     try
     {
         ItemRepository.Update(item);
     }
     catch (Exception)
     {
         return(BadRequest("Error while creating"));
     }
     return(NoContent());
 }
예제 #4
0
        public IActionResult Create([FromBody] Anuncio model, [FromServices] IAnuncioRepository repository)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            model.VendedorId = new Guid(User.Identity.Name);

            repository.Create(model);
            return(Ok());
        }
예제 #5
0
        public CriarAnuncioResponse CriarAnuncio(CriarAnuncioRequest criarAnuncioRequest)
        {
            Anuncio anuncio = new Anuncio();

            anuncio = criarAnuncioRequest.Anuncio;

            CriarAnuncioResponse criarAnuncioResponse = new CriarAnuncioResponse();

            criarAnuncioResponse.Successo = _servicoAnuncio.Cadastrar(anuncio);

            return(criarAnuncioResponse);
        }
예제 #6
0
 public ActionResult Put(int id, [FromBody] Anuncio anuncio)
 {
     try
     {
         appAnuncio.Update(anuncio);
         return(StatusCode(200));
     }
     catch (Exception ex)
     {
         return(StatusCode(500, ex.Message));
     }
 }
예제 #7
0
        public IActionResult Editar([FromServices] Db db, Anuncio param)
        {
            var service  = new AnuncioService(db);
            var response = service.Editar(param);

            response.RotaRetorno = "/Anuncio/Index";
            if (response.IsValidResponse())
            {
                return(Ok(response));
            }
            return(BadRequest(response));
        }
예제 #8
0
 public ActionResult Post([FromBody] Anuncio anuncio)
 {
     try
     {
         appAnuncio.Add(anuncio);
         return(StatusCode(200, 1));
     }
     catch (Exception ex)
     {
         return(StatusCode(500, ex.Message));
     }
 }
예제 #9
0
        public async Task <ReinsertResult> ReInsert(Anuncio anuncio, string Key2Captcha, string email)
        {
            ReinsertResult    result;
            CaptchaAnswer     captchaResponse;
            FormInsertAnuncio formInsertAnuncio;
            FormDeleteAnuncio formDeleteAnuncio;

            try
            {
                // Get Anuncio

                string htmlAnuncio = await Requests.GetAsync(anuncio.Url);

                GetException(htmlAnuncio, anuncio.Url, false);

                // Parse All Data
                FormUpdateAnuncio formAnuncio = ParseFormAnuncio(htmlAnuncio);
                formAnuncio.variables.email = email;
                anuncio.FormUpdateAnuncio   = JsonConvert.SerializeObject(formAnuncio);

                //Solve Captcha
                captchaResponse = await ResolveCaptcha(Key2Captcha, Requests.RevolicoInserrUrl, htmlAnuncio);

                formAnuncio.variables.captchaResponse = captchaResponse.Answerv2;
                //formAnuncio.variables.botScore = captchaResponse.Answerv3;

                // Parse Insert and Delete Forms
                formInsertAnuncio = new FormInsertAnuncio(formAnuncio);
                formDeleteAnuncio = new FormDeleteAnuncio(formAnuncio);

                // Insert new Announce
                string answer = await InsertAnuncio(formInsertAnuncio);

                // Verify Insertion
                GetException(answer, anuncio.Url, true, captchaResponse);

                // Update new Anuncio URL
                InsertResult insertResult = ParseInsertResult(answer);
                anuncio.Url = $"{Requests.RevolicoModifyUrl}?key={insertResult.FullId}";
                _log.LogWarning($"ReplaceInsert {anuncio.Id} {insertResult.FullId}");

                // Delete from Revolico
                await DeleteFromRevolico(formDeleteAnuncio);

                result = new ReinsertResult(anuncio);
            }
            catch (Exception ex)
            {
                result = new ReinsertResult(anuncio, ex);
            }

            return(result);
        }
예제 #10
0
        public ActionResult Create([Bind(Include = "AnuncioID,Descricao,QuartoSolteiro,QuartoCasal,QuartoComunitario,QtdCama,QtdBanheiro,NumHospedes,ValorDiaria,Rua,Bairro,Complemento,Numero,Cidade,UF,Cep,Foto1,Foto2,ArCondicionado,Ventilador,Banheira,Internet,TvCabo,Animais,Fumante,Ativo,ProblemasLocadorID")] Anuncio anuncio)
        {
            if (ModelState.IsValid)
            {
                db.Anuncios.Add(anuncio);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.LocadorID = new SelectList(db.Locadores, "LocadorID", "NomeLocador", anuncio.LocadorID);
            return(View(anuncio));
        }
예제 #11
0
 public async Task <IActionResult> Alterar([FromBody] Anuncio anuncio)
 {
     try
     {
         _servicos.Alterar(anuncio);
         return(Ok(new { message = "Operação realizada com sucesso." }));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
        public int Adicionar(Anuncio request)
        {
            string sql = "" +
                         " INSERT INTO " +
                         " tb_AnuncioWebmotors (Marca, Modelo, Versao, Ano, Quilometragem, Observacao) " +
                         " VALUES  (@Marca, @Modelo, @Versao, @Ano, @Quilometragem, @Observacao);" +
                         " SELECT SCOPE_IDENTITY();";

            var id = _unitOfWork.Connection.ExecuteScalar <int>(sql, request);

            return(id);
        }
예제 #13
0
        public ActionResult Remover(int id)
        {
            Anuncio anuncio = context.Anuncios.Find(id);

            context.Anuncios.Remove(anuncio);

            context.SaveChanges();

            TempData["Message"] = "ANÚNCIO REMOVIDO COM SUCESSO";

            return(RedirectToAction("Listar"));
        }
예제 #14
0
 public IActionResult DetalheAnuncio(Anuncio anuncio)
 {
     if (anuncio == null)
     {
         return(View("Index"));
     }
     else
     {
         anuncio.Usuario = new Usuario().BuscaUsuario(anuncio.UsuarioId);
         return(View(anuncio));
     }
 }
예제 #15
0
 public Anuncio GetAnuncioByID(int id)
 {
     try
     {
         Anuncio an = new Anuncio();
         return(an.BuscarAnuncio(id));
     }
     catch (System.Exception e)
     {
         throw e;
     }
 }
        public ActionResult Create([Bind(Include = "ID,Nome,Data,PessoaID")] Anuncio anuncio)
        {
            if (ModelState.IsValid)
            {
                db.Anuncios.Add(anuncio);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.PessoaID = new SelectList(db.Pessoas, "ID", "Nome", anuncio.PessoaID);
            return(View(anuncio));
        }
        public void Filtrar_UmAnuncioPorDataMinima_Corretamente()
        {
            // Arrange
            Anuncio aSerTestado     = new Anuncio("", "", new DateTime(2000, 09, 01), DateTime.MinValue, 0);
            Anuncio templateCliente = new Anuncio("", "", new DateTime(1999, 01, 01), DateTime.MinValue, 0);

            //Act
            bool TEMPLATE_FOIRECONHECIDO = aSerTestado.Filtar(templateCliente);

            // Assert
            Assert.True(TEMPLATE_FOIRECONHECIDO);
        }
        public void GetAnuncio_UmAnuncio_Corretamente()
        {
            //Arrange
            RepositorioDeAnuncios repositorio = new RepositorioDeAnuncios();
            Anuncio anuncio = new Anuncio("", "", DateTime.MinValue, DateTime.MinValue, 0);

            //Act
            repositorio.AdicionarAnuncio(anuncio);

            //Assert
            Assert.Equal(anuncio, repositorio.GetAnuncio(0));
        }
        public void Filtrar_UmAnuncioPeloCliente_Corretamente()
        {
            // Arrange
            Anuncio aSerTestado     = new Anuncio("", "cliente", DateTime.MinValue, DateTime.MinValue, 0);
            Anuncio templateCliente = new Anuncio("", "cliente", DateTime.MinValue, DateTime.MinValue, 0);

            //Act
            bool TEMPLATE_FOIRECONHECIDO = aSerTestado.Filtar(templateCliente);

            // Assert
            Assert.True(TEMPLATE_FOIRECONHECIDO);
        }
        public ActionResult Create([Bind(Include = "PostID,Foto,Entrada,Precio,Descript,Located,Fecha,UsuarioID")] Anuncio anuncio)
        {
            if (ModelState.IsValid)
            {
                db.Anuncios.Add(anuncio);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.UsuarioID = new SelectList(db.Usuarios, "UsuarioID", "FirstName", anuncio.UsuarioID);
            return(View(anuncio));
        }
        public void Filtrar_UmAnuncioPorPeriodo_Corretamente()
        {
            // Arrange
            Anuncio aSerTestado     = new Anuncio("", "", new DateTime(2001, 01, 01), new DateTime(2001, 01, 01), 0);
            Anuncio templateCliente = new Anuncio("", "", new DateTime(2000, 01, 01), new DateTime(2002, 01, 01), 0);

            //Act
            bool TEMPLATE_FOIRECONHECIDO = aSerTestado.Filtar(templateCliente);

            // Assert
            Assert.True(TEMPLATE_FOIRECONHECIDO);
        }
        public void Filtrar_UmAnuncioPorDataMaxima_Erroneamente()
        {
            // Arrange
            Anuncio aSerTestado     = new Anuncio("", "", DateTime.MinValue, new DateTime(2002, 11, 01), 0);
            Anuncio templateCliente = new Anuncio("", "", DateTime.MinValue, new DateTime(1999, 01, 01), 0);

            //Act
            bool TEMPLATE_FOIRECONHECIDO = aSerTestado.Filtar(templateCliente);

            // Assert
            Assert.False(TEMPLATE_FOIRECONHECIDO);
        }
예제 #23
0
        public NuevoAnuncioView()
        {
            InitializeComponent();

            Item = new Anuncio
            {
                Titulo      = "Nombre",
                Descripcion = "Descripcion."
            };

            BindingContext = this;
        }
예제 #24
0
        public ActionResult Edit(int id)
        {
            Anuncio      anuncio      = _anuncioService.Buscar(id);
            AnuncioModel anuncioModel = _mapper.Map <AnuncioModel>(anuncio);

            IEnumerable <Imovel> listarImoveis = _imovelService.ObterTodos();
            IEnumerable <Pessoa> listarPessoas = _pessoaService.ObterTodos();

            ViewBag.IdImovel = new SelectList(listarImoveis, "CodigoImovel", "Descricao", null);
            ViewBag.IdPessoa = new SelectList(listarPessoas, "CodigoPessoa", "Nome", null);

            return(View(anuncioModel));
        }
예제 #25
0
 public bool Save(Anuncio entity)
 {
     try
     {
         context.Add(entity);
         context.SaveChanges();
     }
     catch (System.Exception)
     {
         return(false);
     }
     return(true);
 }
예제 #26
0
        public ActionResult Filtro([Bind(Include = "TituloAnuncio,Valor")] Anuncio anuncio)
        {
            //metodo de seleçao
            //consultar no banco a partir dos inputs
            //ViewBag.TituloAnuncio = new SelectList(db.Anuncios, "TituloAununcio");
            //ViewBag.Valor = new SelectList(db.Anuncios, "Valor");
            var pesquisaProds = db.Anuncios.Where(p => (p.TituloAnuncio == "TituloAnuncio"));

            ViewBag.pesquisaProds = pesquisaProds;

            return(View(pesquisaProds));
            //return RedirectToAction("Index");
        }
예제 #27
0
        public ActionResult GetImage(int id)
        {
            Anuncio anuncio = db.Anuncios.Find(id);

            if (anuncio != null && anuncio.Imagem.ImageFile != null)
            {
                return(File(anuncio.Imagem.ImageFile, anuncio.Imagem.ImageMimeType));
            }
            else
            {
                return(new FilePathResult("~/Images/1.jpg", "image/jpeg"));
            }
        }
        public async Task <ActionResult <Anuncio> > CadastrarAnuncio([FromBody] Anuncio anuncio)
        {
            try
            {
                await _repositorio.Incluir(anuncio);

                return(CreatedAtAction(nameof(BuscarTodosAnuncios), new { id = anuncio.Id }, anuncio));
            }
            catch (Exception)
            {
                return(BadRequest(new { messageError = "Ocorreu um erro inesperado" }));
            }
        }
예제 #29
0
        public async Task <IActionResult> Update([FromBody] Anuncio anuncio)
        {
            try
            {
                anuncio = await _anuncioAppService.Update(anuncio);

                return(Ok(anuncio));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
예제 #30
0
        public ActionResult MeusAnuncios(Usuario vwUsuario)
        {
            vwUsuario.BuscarAnunciosUsuario();
            Anuncio anuncio = new Anuncio()
            {
                Usuario   = vwUsuario,
                UsuarioId = vwUsuario.ID,
            };

            ViewBag.Message = anuncio.Usuario;

            return(View("MeusAnuncios"));
        }