Exemplo n.º 1
0
        public ActionResult Create(likesdbs likesdbs)
        {
            if (ModelState.IsValid)
            {
                db.likesdbs.Add(likesdbs);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.messageApproved = new SelectList(db.messagesdbs, "messageID", "content", likesdbs.messageApproved);
            ViewBag.liker = new SelectList(db.utilisateursdbs, "ID", "firstname", likesdbs.liker);
            return View(likesdbs);
        }
Exemplo n.º 2
0
        public ActionResult LikeANew(int id)
        {
            likesdbs likesdbs = new likesdbs();
            likesdbs.messageApproved = id;

            my_aspnet_users user = db.my_aspnet_users.Where(a => a.name.Equals(User.Identity.Name)).FirstOrDefault();
            likesdbs.liker = user.id;

            // si l'utilisateur a dejà aimé la nouvelle, on ne fait rien
            //TODO

            try
            {
                db.likesdbs.AddObject(likesdbs);
                db.SaveChanges();

                return RedirectToAction("NewsFeed", "Messages");
            }
            catch
            {
                return RedirectToAction("NewsFeed", "Messages");
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Créez un nouvel objet likesdbs.
 /// </summary>
 /// <param name="id">Valeur initiale de la propriété ID.</param>
 /// <param name="messageApproved">Valeur initiale de la propriété messageApproved.</param>
 /// <param name="liker">Valeur initiale de la propriété liker.</param>
 public static likesdbs Createlikesdbs(global::System.Int32 id, global::System.Int32 messageApproved, global::System.Int32 liker)
 {
     likesdbs likesdbs = new likesdbs();
     likesdbs.ID = id;
     likesdbs.messageApproved = messageApproved;
     likesdbs.liker = liker;
     return likesdbs;
 }
Exemplo n.º 4
0
 //
 // GET: /Like/LikeANew
 public ActionResult LikeANew(int id)
 {
     likesdbs likesdbs = new likesdbs();
     likesdbs.messageApproved = id;
     //likesdbs.liker = User.Identity.Name;
     //db.my_aspnet_user
     if (ModelState.IsValid) // must be useless since no input error can occur
     {
         db.likesdbs.Add(likesdbs);
         db.SaveChanges();
         return RedirectToAction("../Messages/NewsFeed");
     }
     return RedirectToAction("../Messages/NewsFeed");
 }
Exemplo n.º 5
0
 /// <summary>
 /// Méthode déconseillée pour ajouter un nouvel objet à l'EntitySet likesdbs. Utilisez la méthode .Add de la propriété ObjectSet&lt;T&gt; associée à la place.
 /// </summary>
 public void AddTolikesdbs(likesdbs likesdbs)
 {
     base.AddObject("likesdbs", likesdbs);
 }