public async Task <IActionResult> Edit(int id, [Bind("Id,SurfboardId,ContactId,Behandeld")] Interesse interesse)
        {
            if (id != interesse.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(interesse);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InteresseExists(interesse.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ContactId"]   = new SelectList(_context.Contacten, "Id", "Id", interesse.ContactId);
            ViewData["SurfboardId"] = new SelectList(_context.Surfboards, "Id", "Id", interesse.SurfboardId);
            return(View(interesse));
        }
示例#2
0
        public Interesse Create(Interesse obj)
        {
            if (obj == null)
            {
                throw new Exception("O interesse não pode ser nulo");
            }

            Interesse interesse = null;

            obj.id = Guid.NewGuid().ToString();

            #region Verificar se o interesse já está na lista de interesses
            List <Interesse> lstInteresse = _interesseRepository.GetAllByUsuario(obj.usuarioId).ToList();
            if (lstInteresse != null && lstInteresse.Count > 0)
            {
                if (!lstInteresse.Exists(x => x.usuarioId == obj.usuarioId && x.localId == obj.localId))
                {
                    interesse = _interesseRepository.Create(obj);
                }
            }
            else
            {
                interesse = _interesseRepository.Create(obj);
            }
            #endregion

            return(interesse);
        }
        public async Task <Interesse> Delete(Interesse interesse)
        {
            context.Interesse.Remove(interesse);
            await context.SaveChangesAsync();

            return(interesse);
        }
示例#4
0
        public ActionResult ConfirmarTroca(int anuncioID, string userID)
        {
            var anuncio = db.Anuncios.Find(anuncioID);
            var user    = anuncio.pessoa;

            if (user.UserName != User.Identity.Name)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var interesses = Interesse.getInteressesByAnuncio(anuncioID).ToList();

            foreach (var item in interesses)
            {
                var interesse = db.Interesses.Where(i => i.userID == item.userID).Where(i => i.anuncioID == anuncioID).First();
                if (item.userID == userID)
                {
                    interesse.aceito = true;
                }
                else
                {
                    interesse.aceito = false;
                }
                db.Entry(interesse).State = EntityState.Modified;
            }
            anuncio.ativo           = false;
            anuncio.status          = "Terminado";
            db.Entry(anuncio).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index", new { Message = "tradeConfirmed" }));
        }
示例#5
0
        public async Task <ActionResult <Interesse> > Put(int id, Interesse interesse)
        {
            if (id != interesse.IdInteresse)
            {
                return(BadRequest());
            }

            try
            {
                await repositorio.Put(interesse);
            }
            catch (DbUpdateConcurrencyException)
            {
                var validarInteresse = await repositorio.Get(id);

                if (validarInteresse == null)
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(interesse);
        }
示例#6
0
        public IActionResult Cadastrar(Interesse cad)
        {
            DatabaseService dbs = new DatabaseService();

            dbs.CadastraInteresse(cad);
            return(View("Index", cad));
        }
示例#7
0
        public ActionResult Exchange(int anuncioID, string origem)
        {
            if (origem == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            var anuncio = db.Anuncios.Find(anuncioID);

            if (anuncio.pessoa.UserName == User.Identity.Name)
            {
                return(RedirectToAction("Index", new { Message = "sameUser" }));
            }
            var user = db.Users.Where(u => u.UserName == origem).First();

            if (db.Interesses.Where(i => i.anuncioID == anuncio.anuncioID).Where(i => i.userID == user.Id).Count() >= 1)
            {
                return(RedirectToAction("Details/" + anuncioID, new { Message = "interestAlreadyCreated" }));
            }
            var interesse = new Interesse();

            interesse.anuncioID = anuncio.anuncioID;
            interesse.userID    = user.Id;
            interesse.texto     = (anuncio.tipo == "Ofertas" ? "texto oferta" : "texto pedido");
            interesse.aceito    = null;
            db.Interesses.Add(interesse);
            anuncio.status          = "Com interessados";
            db.Entry(anuncio).State = EntityState.Modified;
            db.SaveChanges();
            EmailService.sendNovoInteresseMessage(anuncio.pessoa.UserName, anuncio.pessoa.Email, User.Identity.Name, anuncio.titulo);
            return(RedirectToAction("Index", new { Message = "interestCreated" }));
        }
        public async Task <ActionResult <Interesse> > Put(int id, Interesse interesse)
        {
            if (id != interesse.IdInteresse)
            {
                return(BadRequest());
            }

            try {
                var x = await _interesseRepository.Put(interesse);

                string titulo = "Parabéns " + interesse.FkIdUsuarioNavigation.NomeUsuario + " você foi selecionado - Você acaba de adquirir " + interesse.FkIdAnuncioNavigation.FkIdProdutoNavigation.NomeProduto;

                //Construct the alternate body as HTML

                string corpo = System.IO.File.ReadAllText(path: @"ConteudoEmail.html");

                string anexo = @"C:\Users\fic\Desktop\apostila.pdf";
                EnvioEmail(interesse.FkIdUsuarioNavigation.EmailUsuario, titulo, corpo, anexo);

                return(x);
            }
            catch (DbUpdateException ex) {
                var interesseValido = await _interesseRepository.Get(id);

                if (interesseValido == null)
                {
                    return(NotFound());
                }
                else
                {
                    throw ex;
                }
            }
        }
    protected void btnSalvar_Click(object sender, EventArgs e)
    {
        try
        {
            Interesse esc = new Interesse();
            esc.DesInteresse = txtInteresse.Text;
            if (Sequencial.Value != "")
            {
                esc.Sequencial = Convert.ToInt32(Sequencial.Value);

                if (InteresseDAO.getInstance().update(esc))
                {
                    sucess();
                }
            }
            else
            {
                if (InteresseDAO.getInstance().create(esc))
                {
                    sucess();
                }
            }
        }
        catch (Exception) {
            Server.Transfer("~/Config/Erro.aspx");
        }
    }
        public bool ExcluirInteresse(Interesse inter)
        {
            var curriculoDados = new PerfilCurricular.Models.CurriculoDAL();
            var retExcluir     = curriculoDados.ExcluirInteresse(inter);

            return(retExcluir.Success);
        }
        public async Task <Interesse> Put(Interesse interesse)
        {
            context.Entry(interesse).State = EntityState.Modified;
            await context.SaveChangesAsync();

            return(interesse);
        }
        public async Task <Interesse> Delete(Interesse interesseRetornado)
        {
            _context.Interesse.Remove(interesseRetornado);
            await _context.SaveChangesAsync();

            return(interesseRetornado);
        }
示例#13
0
        public Interesse Create(Interesse obj)
        {
            _context.Interesse.Add(obj);
            _context.SaveChanges();

            return(_context.Interesse.FirstOrDefault(x => x.id == obj.id));
        }
示例#14
0
        public async Task <IActionResult> Put(long id, Interesse interesse)
        {
            if (id != interesse.IdInteresse)
            {
                return(BadRequest());
            }

            context.Entry(interesse).State = EntityState.Modified;

            try
            {
                await context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                var Interesse_valido = await context.Interesse.FindAsync(id);

                if (Interesse_valido == null)
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <Interesse> DemonstrarInteresse(int id, Interesse interesse)
        {
            await context.AddAsync(interesse);

            await context.SaveChangesAsync();

            return(interesse);
        }
示例#16
0
        public Interesse Update(Interesse obj)
        {
            _context.Interesse.Update(obj);
            _context.Entry(obj).State = EntityState.Modified;
            _context.SaveChanges();

            return(_context.Interesse.FirstOrDefault(x => x.id == obj.id));
        }
        public async Task <Interesse> Get(int id)
        {
            Interesse interesse = await context.Interesse.Include(us => us.IdUsuarioNavigation)
                                  .Include(an => an.IdAnuncioNavigation)
                                  .FirstOrDefaultAsync(inte => inte.IdInteresse == id);

            return(interesse);
        }
        public async Task <Interesse> Post(Interesse interesse)
        {
            await context.Interesse.AddAsync(interesse);

            await context.SaveChangesAsync();

            return(interesse);
        }
        public List <string> VerwijderIntresseFromLeerling(int leerlingId, Interesse interesse)
        {
            var leerling = this._leerlingen.FirstOrDefault(l => l.Id == leerlingId);

            leerling.VerwijderInteresse(interesse.InteresseTekst);
            this.SaveChanges();
            leerling.UpdateIntressesFromOpslag();
            return(leerling.Interesses);
        }
 public async Task <ActionResult <Interesse> > Post(Interesse interesse)
 {
     try {
         return(await _interesseRepository.Post(interesse));
     }
     catch (Exception ex) {
         throw ex;
     }
 }
示例#21
0
        public void Delete(Interesse obj)
        {
            if (obj == null)
            {
                throw new Exception("o Interesse não pde ser nulo");
            }

            _interesseRepository.Delete(obj);
        }
示例#22
0
        public Interesse Update(Interesse obj)
        {
            if (obj == null)
            {
                throw new Exception("O Interesse não pode ser nulo");
            }

            return(_interesseRepository.Update(obj));
        }
        public async Task <Interesse> Put(int id, Interesse interesse)
        {
            Interesse interesseRetornado = await context.Interesse.FindAsync(id);

            interesseRetornado.TwmpInteresseCompra = interesse.TwmpInteresseCompra;
            await context.SaveChangesAsync();

            return(interesseRetornado);
        }
        public async Task <ActionResult <Interesse> > GetAction(int id)
        {
            Interesse interesseRetornado = await repositorio.Get(id);

            if (interesseRetornado == null)
            {
                return(NotFound());
            }
            return(interesseRetornado);
        }
示例#25
0
        public ActionResult History(int?page)
        {
            var db         = new ApplicationDbContext();
            var userId     = User.Identity.GetUserId();
            var interesses = Interesse.getInteressesByUser(userId);
            int pageSize   = 10;
            int pageNumber = (page ?? 1);

            return(View(interesses.ToPagedList(pageNumber, pageSize)));
        }
示例#26
0
        public async Task <ActionResult <Interesse> > Id(int id)
        {
            Interesse interesseRetornado = await repositorio.Id(id); //Manda buscar a informação no BD (repositório) e após a resposta eu faço a verificação

            if (interesseRetornado == null)
            {
                return(NotFound());
            }
            return(interesseRetornado); // Retorno da variável com a resposta do repositório
        }
示例#27
0
 public async Task <ActionResult <Interesse> > Post(Interesse interesse)
 {
     try{
         interesse.TwmpInteresseCompra = true;
         return(await repositorio.Post(interesse));                 //Manda cadastrar nformação no BD através do respositório
     }
     catch (System.Exception ex) {                                  // E se houver erro ele mostra qual foi
         return(BadRequest(new{ mensagem = "Erro" + ex.Message })); //BadRequest Mostra o erro, Mensagem (var) mostra qual foi recebendo o erro da exceção
     }
 }
        public async Task <Interesse> Put(Interesse interesse)
        {
            using (TECHCYCLEContext _context = new TECHCYCLEContext())
            {
                _context.Entry(interesse).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                return(interesse);
            }
        }
        public async Task <Interesse> Delete(Interesse interesse)
        {
            using (TECHCYCLEContext _context = new TECHCYCLEContext())
            {
                _context.Interesse.Remove(interesse);
                await _context.SaveChangesAsync();

                return(interesse);
            }
        }
 public async Task <ActionResult <Interesse> > DemonstrarInteresse(int id, Interesse interesse)
 {
     try
     {
         return(await repositorio.DemonstrarInteresse(id, interesse));
     }
     catch (DbUpdateException)
     {
         throw;
     }
 }