示例#1
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" }));
        }
示例#2
0
        public ActionResult Interests(int?page, int anuncioID)
        {
            var user = db.Anuncios.Find(anuncioID).pessoa;

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

            if (interesses.Count == 0)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            int pageSize   = 10;
            int pageNumber = (page ?? 1);

            return(View(interesses.ToPagedList(pageNumber, pageSize)));
        }