public UserResponse(User user) { Id = user.Id; Username = user.Username; Link = $"/users/{Username}"; DisplayName = user.DisplayName; AvatarLink = $"/avatars/{user.AvatarPhoto.FileName}"; Created = user.Created; Followers = user.Followers.Where(f => f.IsActive.Value).Select(f => new { f.FollowerId, f.Follower.Username, f.Follower.DisplayName, AvatarLink = $"/avatars/{f.Follower.AvatarPhoto.FileName}" }); Followings = user.Followings.Where(f => f.IsActive.Value).Select(f => new { f.UserId, f.User.Username, f.User.DisplayName, AvatarLink = $"/avatars/{f.User.AvatarPhoto.FileName}" }); FollowerCount = Followers.Count(); FollowingCount = Followings.Count(); Posts = user.Posts.OrderByDescending(p => p.Created).Select(p => new { p.Id, Link = $"/posts/{p.Id}", LikeCount = p.Likes.Count(l => l.IsActive.Value), CommentCount = p.Comments.Count, Thumbnail = $"/photos/{p.Photos.FirstOrDefault().FileName}" }); }
public async Task <IActionResult> Edit(string id, [Bind("Followers,Following")] Followings followings) { if (id != followings.Followers) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(followings); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FollowingsExists(followings.Followers)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["Followers"] = new SelectList(_context.Profile, "UserId", "UserId", followings.Followers); ViewData["Following"] = new SelectList(_context.Profile, "UserId", "UserId", followings.Following); return(View(followings)); }
public async Task <IActionResult> PutFollowings([FromRoute] int id, [FromBody] Followings followings) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != followings.id) { return(BadRequest()); } _context.Entry(followings).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FollowingsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutFollowings(string id, Followings followings) { if (id != followings.Followers) { return(BadRequest()); } _context.Entry(followings).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FollowingsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
/// <summary> /// Shows the menu items. /// </summary> private async Task ShowMenuItems() { var speed = 25U; await Settings.FadeTo(1, speed); await Followings.FadeTo(1, speed); await UserMap.FadeTo(1, speed); }
public void getFollowings() { ListOfUsers listOfFollwoings = QuoteSharp.API.getUsersListOfFollowings(this.username); Followings.Clear(); foreach (User following in listOfFollwoings.entities) { Followings.Add(QuoteFmUser.createFromApi(following)); } }
public IActionResult Post([FromBody] Followings value) { if (value == null) { return(BadRequest()); } _context.Followings.Add(value); _context.SaveChanges(); return(NoContent()); }
public IActionResult Put(int id, [FromBody] Followings item) { if (item == null || item.Id != id) { return(BadRequest()); } _context.Followings.Update(item); _context.SaveChanges(); return(new NoContentResult()); }
public void Dispose() { Gigs.Dispose(); Attendances.Dispose(); Followings.Dispose(); Genres.Dispose(); UserNotifications.Dispose(); Users.Dispose(); Roles.Dispose(); // UserDescriptions.Dispose(); }
public async Task <IActionResult> PostFollowings([FromBody] Followings followings) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Followings.Add(followings); await _context.SaveChangesAsync(); return(CreatedAtAction("GetFollowings", new { id = followings.id }, followings)); }
public async Task <IActionResult> Create([Bind("Followers,Following")] Followings followings) { if (ModelState.IsValid) { _context.Add(followings); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Followers"] = new SelectList(_context.Profile, "UserId", "UserId", followings.Followers); ViewData["Following"] = new SelectList(_context.Profile, "UserId", "UserId", followings.Following); return(View(followings)); }
public override object Handle(JObject param, string token, InternalUser?me) { var userId = GetRequired <string>(param, "userId"); var offset = GetOptionalValue <int>(param, "offset") ?? 0; var limit = GetOptionalValue <int>(param, "limit") ?? 100; IEnumerable <User> followings = Followings.GetFollowers(userId, offset, limit) .Select(id => Users.Show(id: id)) .Select(u => u?.Pack(me)) .OfType <User>(); return(followings); }
public override object Handle(JObject p, string token, InternalUser?user) { //hack 続きを読めるようにもっとまともな実装にする var u = user !; var posts = Posts.GetAllBy(u.Id); foreach (var uid in Followings.GetFollowings(u.Id)) { posts = posts.Concat(Posts.GetAllBy(uid, u.Id)); } posts = posts.OrderByDescending(p => p.CreatedAt.Ticks).Take(100); return(posts); }
public async Task<ActionResult> AddCompany(long id, long cid) { var user = db.UserSet.Find(id); if ( !user.Followings.Any(x => x.CompanyId == cid)) { var company = db.CompanySet.Find(cid); var follow = new Followings(); follow.Company = company; follow.User =user; company.Followings.Add(follow); await db.SaveChangesAsync(); } return RedirectToAction("Index", new { id = id }); }
public async Task <ActionResult> AddCompany(long id, long cid) { var user = db.UserSet.Find(id); if (!user.Followings.Any(x => x.CompanyId == cid)) { var company = db.CompanySet.Find(cid); var follow = new Followings(); follow.Company = company; follow.User = user; company.Followings.Add(follow); await db.SaveChangesAsync(); } return(RedirectToAction("Index", new { id = id })); }
public async Task <ActionResult <Followings> > PostFollowings(Followings followings) { _context.Followings.Add(followings); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (FollowingsExists(followings.Followers)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetFollowings", new { id = followings.Followers }, followings)); }
public async Task <IActionResult> SaveFollowing(int follow, int idItem) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } //Take ID DSSize Table var takeIdDsSize = _context.ds_Size.Where(p => p.VN == follow).FirstOrDefault().id; //Take ID Size Table var takeIdSize = _context.Sizes.Where(p => p.id_ds_size == takeIdDsSize && p.id_item == idItem).FirstOrDefault().id; if (String.IsNullOrEmpty(HttpContext.Session.GetInt32("idUser").ToString())) { return(BadRequest("Please Login For Following!")); } //Take ID User var takeIdUser = HttpContext.Session.GetInt32("idUser").Value; //Count Row in Following Talbe var count = _context.Followings.Where(p => p.id_size == takeIdSize && p.id_user == takeIdUser).Count(); if (count > 0) { return(BadRequest("This size is followed in your account!")); } Followings fol = new Followings(); fol.id_user = takeIdUser; fol.id_size = takeIdSize; _context.Followings.Add(fol); await _context.SaveChangesAsync(); return(Ok()); }
void multiple_belongs_to_columns_referencing_the_same_table() { before = () => { familys = new Familys(); followings = new Followings(); seed.PurgeDb(); seed.CreateTable("Familys", new dynamic[] { seed.Id(), new { Name = "nvarchar(255)" } }).ExecuteNonQuery(); seed.CreateTable("Followings", new dynamic[] { seed.Id(), new { FamilyId = "int" }, new { FollowingId = "int" } }).ExecuteNonQuery(); var userId = new { Name = "jane" }.InsertInto("Familys"); var userId2 = new { Name = "john" }.InsertInto("Familys"); new { FamilyId = userId, FollowingId = userId2 }.InsertInto("Followings"); }; it["both belongs to references are accessible"] = () => { var firstFollowing = followings.All().First(); (firstFollowing.Family().Name as string).should_be("jane"); (firstFollowing.Following().Name as string).should_be("john"); }; }
public IHttpActionResult Follow(FollowingsDto dto) { var userId = User.Identity.GetUserId(); var exists = _db.Followings.Any(f => f.FollowerId == userId && f.FolloweeId == dto.ArtistId); // followee means the artist, user trying to follow; if (exists) { return(BadRequest("you are already folloing the artist")); } var following = new Followings() { FolloweeId = dto.ArtistId, FollowerId = userId }; _db.Followings.Add(following); _db.SaveChanges(); return(Ok()); }
public void Generate() { //randoms Random rnd = new Random(); var streets = new List <string> { "Lipowa", "Warszawska", "Magnata", "Ulkowska", "Jarzębska", "Żadna" }; var names = new List <string> { "Ryszard", "Jadwiga", "Mariusz", "John", "Helmut", "Barbara" }; var cnames = new List <string> { "Maltex", "Kuraż", "Dentix", "Xanox", "Iga", "Świeżo" }; var dom = new List <string> { "@gmail.com", "@hotmail.com", "@op.pl", "@wp.pl", "@onet.pl", "@dragon.com" }; //City var cities = new List <City>() { { new City { Name = "Warszawa" } }, { new City { Name = "Wrocław" } }, { new City { Name = "Zakopane" } }, { new City { Name = "Gdańsk" } } }; DB.CitySet.AddRange(cities); DB.SaveChanges(); //Branch var branches = new List <Branch> { { new Branch { Name = "Uroda", Description = "Salon fryzjerski, kosmetyczny" } }, { new Branch { Name = "Medycyna", Description = "Dentysta, gabinet lekarski" } }, { new Branch { Name = "Motoryzacja", Description = "Warsztat samochodowy, wulkanizator" } }, { new Branch { Name = "Gastronomia", Description = "Restauracje, fast-food" } } }; DB.BranchSet.AddRange(branches); DB.SaveChanges(); //Company for (int i = 0; i < cnames.Count; i++) { var c = new Company(); c.Adress = streets.PickRandom() + " " + rnd.Next(1, 80); c.Branch = DB.BranchSet.PickRandom(); c.Name = cnames[i]; c.NIP = rnd.Next(100, 999).ToString() + "-" + rnd.Next(100, 999).ToString() + "-" + rnd.Next(10, 99).ToString() + "-" + rnd.Next(10, 99).ToString(); c.ChannelName = c.Name; c.Phonenumber = "+48 " + rnd.Next(100000000, 999999999).ToString(); c.City = DB.CitySet.PickRandom(); c.Email = c.Name + dom.PickRandom(); c.Password = TestHelpers.GenerateCode(6); DB.CompanySet.Add(c); } DB.SaveChanges(); //User for (int i = 0; i < count * 3; i++) { var c = new User(); c.Surname = streets.PickRandom(); c.Name = names.PickRandom(); c.DeviceToken = TestHelpers.GenerateCode(12); c.Password = TestHelpers.GenerateCode(8); c.RegistrationId = TestHelpers.GenerateCode(14); c.Phonenumber = rnd.Next(100000000, 999999999).ToString(); c.Email = c.Name + dom.PickRandom(); DB.UserSet.Add(c); } DB.SaveChanges(); //Followings foreach (var item in DB.UserSet) { if (rnd.Next(0, 100) >= 80) { var f = new Followings(); f.User = item; f.Company = DB.CompanySet.PickRandom(); DB.FollowingsSet.Add(f); } } DB.SaveChanges(); ////Push //for (int i = 0; i < count; i++) //{ // var c = new Push(); // // if (rnd.Next(0,1) == 1) // c.Company = DB.CompanySet.PickRandom(); // c.Available = true; // c.DateBegin = DateTime.Today; // c.DateEnd = c.DateBegin.AddHours(rnd.Next(4, 48)); // c.Description = TestHelpers.GenerateText(64); // c.Text = TestHelpers.GenerateText(32); // DB.PushSet.Add(c); //} //DB.SaveChanges(); }
public void Generate() { //randoms Random rnd = new Random(); var streets = new List<string> { "Lipowa", "Warszawska", "Magnata", "Ulkowska", "Jarzębska", "Żadna" }; var names = new List<string> { "Ryszard", "Jadwiga", "Mariusz", "John", "Helmut", "Barbara" }; var cnames = new List<string> { "Maltex", "Kuraż", "Dentix", "Xanox", "Iga", "Świeżo" }; var dom = new List<string> { "@gmail.com", "@hotmail.com", "@op.pl", "@wp.pl", "@onet.pl", "@dragon.com" }; //City var cities = new List<City>() { {new City { Name = "Warszawa" } }, {new City { Name = "Wrocław" } }, {new City { Name = "Zakopane" } }, {new City { Name = "Gdańsk" } } }; DB.CitySet.AddRange(cities); DB.SaveChanges(); //Branch var branches = new List<Branch> { {new Branch { Name = "Uroda", Description = "Salon fryzjerski, kosmetyczny"} }, {new Branch { Name = "Medycyna", Description = "Dentysta, gabinet lekarski" } }, {new Branch { Name = "Motoryzacja", Description = "Warsztat samochodowy, wulkanizator" } }, {new Branch { Name = "Gastronomia", Description = "Restauracje, fast-food" } } }; DB.BranchSet.AddRange(branches); DB.SaveChanges(); //Company for (int i = 0; i < cnames.Count; i++) { var c = new Company(); c.Adress = streets.PickRandom() + " " + rnd.Next(1, 80); c.Branch = DB.BranchSet.PickRandom(); c.Name = cnames[i]; c.NIP = rnd.Next(100, 999).ToString() + "-" + rnd.Next(100, 999).ToString() + "-" + rnd.Next(10, 99).ToString() + "-" + rnd.Next(10, 99).ToString(); c.ChannelName = c.Name; c.Phonenumber = "+48 " + rnd.Next(100000000, 999999999).ToString(); c.City = DB.CitySet.PickRandom(); c.Email = c.Name + dom.PickRandom(); c.Password = TestHelpers.GenerateCode(6); DB.CompanySet.Add(c); } DB.SaveChanges(); //User for (int i = 0; i < count*3; i++) { var c = new User(); c.Surname = streets.PickRandom(); c.Name = names.PickRandom(); c.DeviceToken = TestHelpers.GenerateCode(12); c.Password = TestHelpers.GenerateCode(8); c.RegistrationId = TestHelpers.GenerateCode(14); c.Phonenumber = rnd.Next(100000000, 999999999).ToString(); c.Email = c.Name + dom.PickRandom(); DB.UserSet.Add(c); } DB.SaveChanges(); //Followings foreach (var item in DB.UserSet) { if (rnd.Next(0, 100) >= 80) { var f = new Followings(); f.User = item; f.Company = DB.CompanySet.PickRandom(); DB.FollowingsSet.Add(f); } } DB.SaveChanges(); ////Push //for (int i = 0; i < count; i++) //{ // var c = new Push(); // // if (rnd.Next(0,1) == 1) // c.Company = DB.CompanySet.PickRandom(); // c.Available = true; // c.DateBegin = DateTime.Today; // c.DateEnd = c.DateBegin.AddHours(rnd.Next(4, 48)); // c.Description = TestHelpers.GenerateText(64); // c.Text = TestHelpers.GenerateText(32); // DB.PushSet.Add(c); //} //DB.SaveChanges(); }
/// <summary> /// Adds tap gesture recognizer to open button in the middle of round menu. /// </summary> private void ConnectOpenWithClick() { InnerButtonMenu.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(async () => { if (!isAnimating) { isAnimating = true; InnerButtonClose.IsVisible = true; InnerButtonMenu.IsVisible = true; InnerButtonMenu.RotateTo(360, animationDelay); InnerButtonMenu.FadeTo(0, animationDelay); InnerButtonClose.RotateTo(360, animationDelay); InnerButtonClose.FadeTo(1, animationDelay); await OuterCircle.ScaleTo(3.3, 1000, Easing.BounceIn); await ShowMenuItems(); InnerButtonMenu.IsVisible = false; isAnimating = false; } }), NumberOfTapsRequired = 1 }); } /// <summary> /// Closes the menu. /// </summary> private async Task CloseMenu() { if (!isAnimating) { isAnimating = true; InnerButtonMenu.IsVisible = true; InnerButtonClose.IsVisible = true; await HideMenuItems(); InnerButtonClose.RotateTo(0, animationDelay); InnerButtonClose.FadeTo(0, animationDelay); InnerButtonMenu.RotateTo(0, animationDelay); InnerButtonMenu.FadeTo(1, animationDelay); await OuterCircle.ScaleTo(1, 400, Easing.BounceOut); InnerButtonClose.IsVisible = false; isAnimating = false; } } /// <summary> /// Hides the menu items. /// </summary> private async Task HideMenuItems() { var speed = 25U; await Settings.FadeTo(0, speed); await Followings.FadeTo(0, speed); await UserMap.FadeTo(0, speed); } /// <summary> /// Shows the menu items. /// </summary> private async Task ShowMenuItems() { var speed = 25U; await Settings.FadeTo(1, speed); await Followings.FadeTo(1, speed); await UserMap.FadeTo(1, speed); } } }
IEnumerable <FollowingReportFields> FillData() { return(Followings.Select(following => new FollowingReportFields(following.FollowingDate, following.FollowingDestination, following.FollowingDescription))); }