public String DoLike(int exId) { int uid = (int)Session["id"]; try { like lk = db.likes.First(l => l.expid == exId && l.userid == uid); db.likes.Remove(lk); db.SaveChanges(); } catch (Exception ex) { like l = new like(); l.userid = uid; l.expid = exId; db.likes.Add(l); db.SaveChanges(); } experience e = db.experiences.Find(exId); return(e.likes.Count + ""); //get user id from Session // check either this person already likes this post. // Exceptio ===> make like object, set values, Add to db, save changes. }
public IActionResult AddLike(like like) { string button; like.userId = _context.Users.FirstOrDefault(u => u.UserName == User.Identity.Name).Id; // Проверяем есть ли лайк в базе данных if (_context.posts.Include(l => l.likes).FirstOrDefault(p => p.ID == like.postID).likes.FirstOrDefault(l => l.userId == like.userId && l.postID == like.postID) == null) { // Добавляем лайк _context.posts.FirstOrDefault(p => p.ID == like.postID).likes.Add(like); _context.SaveChanges(); button = "<i class='far fa-heart text-danger font-weight-bold'></i>"; } else { // Убираем лайк _context.likes.Remove(_context.likes.FirstOrDefault(l => l.postID == like.postID && l.userId == like.userId)); _context.SaveChanges(); button = "<i class='far fa-heart'></i>"; } //var count = _context.posts.Include(l=>l.likes).FirstOrDefault(p => p.ID == like.postID).likes.Count(); return(Content(button)); }
public async Task <IActionResult> LikeUser(int id, int recipientId) { // to valadation of user is same edit of my data if (id != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value)) { return(Unauthorized()); } var like = await _repo.GetLike(id, recipientId); if (like != null) { return(BadRequest("You already Like this user")); } if (await _repo.GetUser(recipientId, false) == null) { return(NotFound()); } like = new like { LikerId = id, LikeeId = recipientId }; _repo.Add <like>(like); if (await _repo.SaveAll()) { return(Ok()); } return(BadRequest("Failed to like user")); }
public async Task <IHttpActionResult> likeGroup(like like) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } like.liked_type = "group"; db.likes.Add(like); db.SaveChanges(); var new_notifi = new cls_notifi { source_name = "group", source_id = like.liked_id.ToString(), image = db.AspNetUsers.FirstOrDefault(x => x.Id == like.user_id).Photo,//"no image", body_English = db.AspNetUsers.FirstOrDefault(x => x.Id == like.user_id).UserName + " likes your work group " + db.work_group.FirstOrDefault(x => x.id == like.liked_id).name, body_Arabic = "اعجب " + db.AspNetUsers.FirstOrDefault(x => x.Id == like.user_id).UserName + " بإنشاء مجموعتك " + db.work_group.FirstOrDefault(x => x.id == like.liked_id).name, timestamp = DateTime.Now, readed = false }; var Group_admin = db.work_group.FirstOrDefault(x => x.id == like.liked_id).admin; await Push(new_notifi, "notifications/" + Group_admin.ToString() + "/" + DateTime.UtcNow.ToString("dd-MM-yyyy")); PushNotifi(db.AspNetUsers.FirstOrDefault(x => x.Id == Group_admin).DeviceToken, "More Likes", new_notifi.body_English, "group", like.liked_id.ToString()); return(CreatedAtRoute("DefaultApi", new { id = like.id }, like)); }
public void DeleteLike(int id) { string currid = Request.Params["id"].ToString(); user us = Session["User" + currid] as user; like likes = new like(); likes = db.likes.Where(m => m.liker_id == us.id && m.Newsfeed_id == id).ToList().First(); db.likes.Remove(likes); db.SaveChanges(); }
public async Task add(like like) { using (var context = new ApplicationDbContext(options)) { if (like != null) { context.likes.Add(like); await context.SaveChangesAsync(); } } }
private void updaterow(int rollno, int markstatus) { using (var myDB = new webDbEntities()) { int loggeduserid = Convert.ToInt32(Session["currentuser"]); int activityid = rollno; var loggeduser = (from u in myDB.like where u.user_id == loggeduserid && u.activity_id == activityid select u).FirstOrDefault(); if (loggeduser != null) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('Daha önce like veya dislike vermişsiniz. Like veya dislike verdiğiniz değerler değişmedi.')", true); } else { string loggedusername = Session["currentuser_username"].ToString(); var likeekle = (from u in myDB.user where u.username == loggedusername select u).FirstOrDefault(); if (likeekle != null) { var newlike = new like(); newlike.activity_id = rollno; newlike.user_id = loggeduserid; if (markstatus == 1) { newlike.total = Convert.ToInt32(markstatus); myDB.like.Add(newlike); myDB.SaveChanges(); } else { newlike.min = 1; myDB.like.Add(newlike); myDB.SaveChanges(); } activity act = (from u in myDB.activity where u.id == newlike.activity_id select u).FirstOrDefault(); if (newlike.total == 1) { act.TotalLike++; act.score++; } else { act.TotalDislike++; act.score--; } myDB.SaveChanges(); } } } }
public IHttpActionResult Dislike(like like) { like likeToRemove = db.likes.FirstOrDefault(x => x.liked_id == like.liked_id && x.liked_type == like.liked_type && x.user_id == like.user_id); if (likeToRemove == null) { return(NotFound()); } db.likes.Remove(likeToRemove); db.SaveChanges(); return(Ok(likeToRemove)); }
public IHttpActionResult likeGroupComment(like like) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } like.liked_type = "groupcomment"; db.likes.Add(like); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = like.id }, like)); }
public string UnlikeThis(int id) { blog blg = db.blogs.FirstOrDefault(x => x.id == id); if (User.Identity.IsAuthenticated || Session["user"] != null) { user thisUser = (user)(Session["user"]); user d = db.users.FirstOrDefault(x => x.email == thisUser.email); like l = db.likes.FirstOrDefault(x => x.blog_id == id && x.user_id == d.id); blg.mylikes--; db.likes.Remove(l); db.SaveChanges(); } return(blg.mylikes.ToString()); }
public void AddLike(int id) { string currid = Request.Params["id"].ToString(); user us = Session["User" + currid] as user; like likes = new like(); NewsFeed feed = db.NewsFeeds.Find(id); notification notif = new notification(); notif.state = 1; notif.sender_id = us.id; notif.user_id = feed.user_id; notif.text_id = 6; notif.on_feed_id = id; db.notifications.Add(notif); likes.Newsfeed_id = id; likes.liker_id = us.id; db.likes.Add(likes); db.SaveChanges(); }
public string LikeThis(int id) { dynamic mymodel = new ExpandoObject(); blog blg = db.blogs.FirstOrDefault(x => x.id == id); if (User.Identity.IsAuthenticated || Session["user"] != null) { user thisUser = (user)(Session["user"]); user e = db.users.FirstOrDefault(x => x.email == thisUser.email); blg.mylikes++; like like = new like(); like.blog_id = id; like.user_id = e.id; like.liked = true; db.likes.Add(like); db.SaveChanges(); } return(blg.mylikes.ToString()); }
Usage Use the OnGUI functions (like GUI.DrawTexture or GUI.Button) normally. However instead of Rect, now type ScaledRect.scaledRect.
New fps option to update slower if the animation doesn't need to fluent (like for particle systems)