protected void btn_follow_Click(object sender, EventArgs e) { follower fr = new follower(); following fi = new following(); fr.followers_id = int.Parse(Session["uid"].ToString()); fr.uid = uid; fr.status = "following"; fta.followers.Add(fr); fi.following_id = uid; fi.uid = int.Parse(Session["uid"].ToString()); fta.followings.Add(fi); fta.SaveChanges(); var followers = (from x in fta.followers where x.uid == uid select x.followers_id).Count(); int a = int.Parse(Session["uid"].ToString()); var following = (from y in fta.followings where y.uid == a select y.following_id).Count(); userprofile pf = fta.userprofiles.Where(x => x.uid == uid).FirstOrDefault(); pf.followers = followers; userprofile pfa = fta.userprofiles.Where(x => x.uid == a).FirstOrDefault(); pfa.following = following; fta.SaveChanges(); String url = "profileuser.aspx?id=" + uid; Response.Redirect(url); }
public IHttpActionResult Postfollower(follower follower) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.followers.Add(follower); try { db.SaveChanges(); } catch (DbUpdateException) { if (followerExists(follower.UserId)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = follower.UserId }, follower)); }
public IHttpActionResult Putfollower(string id, follower follower) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != follower.UserId) { return(BadRequest()); } db.Entry(follower).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!followerExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Follow(string submit) { user currentUser = Session["user"] as user; long uid = (long)Convert.ToDouble(submit); using (var entities = new ifollowdatabaseEntities4()) { currentUser = entities.users.First(u => u.id == currentUser.id); follower fol = new follower(); fol.followedId = uid; fol.followerId = currentUser.id; entities.followers.Add(fol); try { entities.SaveChanges(); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); } } } } return(RedirectToAction("Followers", "Wall")); }
public async Task <JsonResult> UploadFile() { string id = Request.Params["id"].ToString(); user us = Session["User" + id] as user; var result = new LinkedList <object>(); try { if (Request.Files.Count != 0) { foreach (string fil in Request.Files) { follower folower = new follower(); NewsFeed feed = new NewsFeed(); HttpPostedFileBase file = Request.Files[fil] as HttpPostedFileBase; if (file.ContentLength == 0) { continue; } Int32 unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; var fileName = Path.GetFileName(file.FileName); var ext = Path.GetExtension(file.FileName); fileName = unixTimestamp.ToString() + fileName.ToString(); string part = "~/Content/Photos/" + (unixTimestamp + 1).ToString() + fileName; var path = Path.Combine(Server.MapPath("~/Content/Photos/"), (unixTimestamp + 1).ToString() + fileName); file.SaveAs(path); if (ext == ".png" || ext == ".jpg" || ext == ".jpeg") { result.AddLast(new { photo = part, video = "", }); } else if (ext == ".ogg" || ext == ".mp4" || ext == ".webm") { result.AddLast(new { video = part, photo = "", }); } else { ViewBag.inputError = "wrong extention"; } } } } catch (Exception e) { } return(Json(result, JsonRequestBehavior.AllowGet)); }
public void ConfimRequest() { string currid = Request.Params["id"].ToString(); int id = int.Parse(Request.Params["id1"].ToString()); int notifID = int.Parse(Request.Params["notifID"]); user us = Session["User" + currid] as user; //delete current notification notification not = db.notifications.Where(n => n.id == notifID).ToList().First(); db.notifications.Remove(not); db.SaveChanges(); //sent response notification notification notif = new notification(); notif.user_id = id; notif.sender_id = us.id; notif.text_id = 4; notif.state = 1; notif.datetime = DateTime.Now; db.notifications.Add(notif); db.SaveChanges(); //add to friend; friend friends = new friend(); friends.user_id = us.id; friends.friend_user_id = id; db.friends.Add(friends); //add to followers follower folow = new follower(); folow.user_id = us.id; folow.follower_id = id; db.followers.Add(folow); follower folow2 = new follower(); folow2.user_id = id; folow2.follower_id = us.id; db.followers.Add(folow2); try { db.SaveChanges(); Response.Write("ok"); } catch (Exception e) { Response.Write("Sorry something wen't wrong - " + e.InnerException.ToString() + "x=" + id); } }
public void AddFollow() { string currId = Request.Params["id"].ToString(); int id = int.Parse(Request.Params["id1"]); user us = Session["User" + currId] as user; follower folow = new follower(); folow.follower_id = us.id; folow.user_id = id; db.followers.Add(folow); try { db.SaveChanges(); Response.Write("ok"); }catch (Exception e) { Response.Write("Sorry something wen't wrong - " + e.InnerException.ToString() + "x=" + id); } }
public void UnFollow() { string currId = Request.Params["id"].ToString(); int id = int.Parse(Request.Params["id1"]); user us = Session["User" + currId] as user; follower folow = new follower(); folow = db.followers.Where(m => m.user_id == id && m.follower_id == us.id).ToList().First(); try { db.followers.Remove(folow); db.SaveChanges(); } catch (Exception e) { Response.Write("Sorry something wen't wrong - " + e.InnerException.ToString() + "x=" + id); } }
public async Task <ActionResult> Index(int id) { //add your shares into your newsfeed user us = Session["User" + id.ToString()] as user; follower folower1 = new follower(); NewsFeed feed1 = new NewsFeed(); if (Request.Params["area1"] != null && Request.Params["area1"].ToString() != "") { feed1.user_id = us.id; feed1.contetnfeed = Request.Params["area1"].ToString(); feed1.dateTime = DateTime.Now; feed1.feedState_id = 1; db.NewsFeeds.Add(feed1); db.SaveChanges(); TempData["id"] = id; return(RedirectToAction("Index")); } TempData["id"] = id; return(RedirectToAction("Index")); }