Ejemplo n.º 1
0
        public ActionResult AddLike(int id, int iduser)
        {
            if (iduser == 0)
            {
                msg = "Sorry, you have to connect";
                return(RedirectToAction("Login"));
            }
            else
            {
                var   listf = Ls.GetAll();
                likes l     = new likes();
                l.idmessage = id;
                l.iduser    = iduser;

                l.date = DateTime.Now;
                messages messages = Ms.GetById(id);
                messages.nbLike = messages.nbLike + 1;
                Ms.Update(messages);
                Ms.Commit();


                Ls.Add(l);
                Ls.Commit();
                return(RedirectToAction("ViewTopic", new
                {
                    id = messages.topic.idTopic,
                    idRep = id,
                }));
            }
        }