public ActionResult GetUserProfile() { string token = Request.Cookies["UserToken"].Value; using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:51639"); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Add("x-token", token); var res = client.GetAsync($"/api/identity/getUserProfile").Result; if (res.IsSuccessStatusCode == true) { var res2 = res.Content.ReadAsAsync <UserIdentityModel>().Result; SocialViewModel res3 = new SocialViewModel(); res3.UserIdentityModel = res2; return(View(res3)); } else { return(Content("res.StatusCode = false :/")); } } }
public async Task <IActionResult> Edit(int id, SocialViewModel viewModel) { if (ModelState.IsValid) { viewModel.Name = viewModel.Name.Trim(); var social = await _db.SocialRepository.GetAsync(id); if (social != null) { _mapper.Map(viewModel, social); _db.SocialRepository.Update(social); await _db.SaveAsync(); return(Redirect("/Admin/Social")); } else { return(NotFound()); } } else { return(View(viewModel)); } }
public override ActionResult Index(int id) { SocialMetrics metrics = this.metricsService.GetSocialMetrics(id); var viewModel = new SocialViewModel(metrics); return(this.MetricsView("Social", viewModel)); }
private string GetCountryAndCityInfo(int projectId, long[] usersListIds) { var cities = this.metricsService.GetMostPopularCities(projectId, usersListIds); var result = SocialViewModel.GetLocations(cities); JavaScriptSerializer serializer = new JavaScriptSerializer(); return(serializer.Serialize(result)); }
private async Task <UserViewModel> AutoProvisionUserAsync(string provider, string providerUserId, IEnumerable <Claim> claims) { // create a list of claims that we want to transfer into our store var filtered = new List <Claim>(); // user's display name var name = claims.FirstOrDefault(x => x.Type == JwtClaimTypes.Name)?.Value ?? claims.FirstOrDefault(x => x.Type == ClaimTypes.Name)?.Value; if (name != null) { filtered.Add(new Claim(JwtClaimTypes.Name, name)); } else { var first = claims.FirstOrDefault(x => x.Type == JwtClaimTypes.GivenName)?.Value ?? claims.FirstOrDefault(x => x.Type == ClaimTypes.GivenName)?.Value; var last = claims.FirstOrDefault(x => x.Type == JwtClaimTypes.FamilyName)?.Value ?? claims.FirstOrDefault(x => x.Type == ClaimTypes.Surname)?.Value; if (first != null && last != null) { filtered.Add(new Claim(JwtClaimTypes.Name, first + " " + last)); } else if (first != null) { filtered.Add(new Claim(JwtClaimTypes.Name, first)); } else if (last != null) { filtered.Add(new Claim(JwtClaimTypes.Name, last)); } } // email var email = claims.FirstOrDefault(x => x.Type == JwtClaimTypes.Email)?.Value ?? claims.FirstOrDefault(x => x.Type == ClaimTypes.Email)?.Value; if (email != null) { filtered.Add(new Claim(JwtClaimTypes.Email, email)); } //picture var picture = claims.FirstOrDefault(x => x.Type == JwtClaimTypes.Picture)?.Value ?? claims.FirstOrDefault(x => x.Type == "image")?.Value; var user = new SocialViewModel() { Username = email, Name = name, Email = email, Picture = picture, Provider = provider, ProviderId = providerUserId }; await _userAppService.RegisterWithoutPassword(user); return(await _userAppService.FindByProviderAsync(provider, providerUserId)); }
public ActionResult CreatePost() { SocialViewModel s = new SocialViewModel { PostDTO = new Models.PostDTO() }; return(PartialView(s)); }
/// <summary> /// INDEX /// </summary> /// <returns></returns> public ActionResult Index() { var name = Session["Username"]; E_Users result = db.E_Userss.SqlQuery("Select * from E_Users where Username=@p0", name).FirstOrDefault(); SocialViewModel mysocialviewmodel = new SocialViewModel(); mysocialviewmodel.E_users = result; return(View(mysocialviewmodel)); }
public PartialViewResult NavBar() { var name = Session["Username"]; E_Users usr = db.E_Userss.SqlQuery("Select * from E_Users where Username=@p0", name).FirstOrDefault(); SocialViewModel views = new SocialViewModel(); views.E_users = usr; return(PartialView("_NavBar", views)); }
public ActionResult CreateComment() { SocialViewModel s = new SocialViewModel { CommentDTO = new Models.CommentDTO() }; return(PartialView(s)); //need to add which page to return }
public ActionResult GetFrnInfo(String id) { E_Users user = db.E_Userss.SqlQuery("Select * from E_Users where ID=@p0 ", id).SingleOrDefault(); SocialViewModel mysocialviewmodel = new SocialViewModel(); mysocialviewmodel.E_users = user; return(PartialView("Profile", mysocialviewmodel)); }
public IActionResult Create(SocialViewModel viewModel) { if (ModelState.IsValid) { _dashboard.AddSocial(viewModel); return(RedirectToAction(nameof(Index))); } return(View(viewModel)); }
public IActionResult Edit(SocialViewModel viewModel, Guid id) { if (ModelState.IsValid) { _dashboard.UpdateSocial(viewModel, id); return(RedirectToAction(nameof(Index))); } return(View(viewModel)); }
public ActionResult ProfileViewUser(String id) { Convert.ToInt32(id); E_Users user = new E_Users(); E_Users result = db.E_Userss.SqlQuery("Select * from E_Users where ID=@p0", id).FirstOrDefault(); SocialViewModel mysocialviewmodel = new SocialViewModel(); mysocialviewmodel.E_users = result; return(View(mysocialviewmodel)); }
public ActionResult GetUserProfile(SocialViewModel identityModel) { string token = Request.Cookies["UserToken"].Value; if (!ModelState.IsValid) { return(View(identityModel)); } else { using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:51639"); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Add("x-token", token); var res = client.PostAsJsonAsync($"/api/identity/updateUserProfile", identityModel.UserIdentityModel).Result; if (res.IsSuccessStatusCode == true) { var res2 = res.Content.ReadAsAsync <UserIdentityModel>().Result; identityModel.UserIdentityModel = res2; //save Identity in cookies HttpCookie NameIdentityProfile = new HttpCookie("My_Name"); NameIdentityProfile.Value = identityModel.UserIdentityModel.Name.ToString(); Response.Cookies.Add(NameIdentityProfile);/// HttpCookie AgeIdentityProfile = new HttpCookie("My_Age"); AgeIdentityProfile.Value = identityModel.UserIdentityModel.Age.ToString(); Response.Cookies.Add(AgeIdentityProfile);/// HttpCookie AddressIdentityProfile = new HttpCookie("My_Address"); AddressIdentityProfile.Value = identityModel.UserIdentityModel.Address.ToString(); Response.Cookies.Add(AddressIdentityProfile);/// HttpCookie WorkPlaceIdentityProfile = new HttpCookie("My_WorkPlace"); WorkPlaceIdentityProfile.Value = identityModel.UserIdentityModel.WorkPlace.ToString(); Response.Cookies.Add(WorkPlaceIdentityProfile);/// TempData.Add("social", identityModel); return(RedirectToAction("MainPageAfterLogin", "Home", identityModel)); } else { return(Content("res.StatusCode = false :/")); } } } }
public async Task <IActionResult> Social() { var user = await GetCurrentUserAsync(); var token = await _appsContainer.AccessToken(); var model = new SocialViewModel(user) { Accounts = (await _userService.ViewSocialAccountsAsync(token, user.Id)).Items, Providers = _authProviders }; return(View(model)); }
public async Task <IActionResult> Edit(Guid id) { Social social = await _dashboard.GetSocial(id); SocialViewModel viewModel = new SocialViewModel() { Address = social.Address, Color = social.Color, Icon = social.Icon, Name = social.Name, OrderShow = social.OrderShow }; return(View(viewModel)); }
/// <summary> /// PROFILES /// </summary> /// <returns></returns> public new ActionResult Profile() { if (Session["ID"] != null) { var id = Session["ID"]; E_Users user = new E_Users(); E_Users result = db.E_Userss.SqlQuery("Select * from E_Users where ID=@p0", id).FirstOrDefault(); SocialViewModel mysocialviewmodel = new SocialViewModel(); mysocialviewmodel.E_users = result; return(View(mysocialviewmodel)); } else { return(RedirectToAction("Login")); } }
public IViewComponentResult Invoke(Common.SocialPosition socialPosition) { var viewModel = new SocialViewModel() { FacebookLink = _systemService.GetSystemParameter(Common.SystemParameterType.FacebookLink), FacebookFollowers = _systemService.GetSystemParameter(Common.SystemParameterType.FacebookFollowers), TwitterLink = _systemService.GetSystemParameter(Common.SystemParameterType.TwitterLink), TwitterFollowers = _systemService.GetSystemParameter(Common.SystemParameterType.TwitterFollowers), GoogleLink = _systemService.GetSystemParameter(Common.SystemParameterType.GoogleLink), GoogleFollowers = _systemService.GetSystemParameter(Common.SystemParameterType.GoogleFollowers), InstagramLink = _systemService.GetSystemParameter(Common.SystemParameterType.InstagramLink), InstagramFollowers = _systemService.GetSystemParameter(Common.SystemParameterType.InstagramFollowers), }; var viewName = socialPosition == Common.SocialPosition.Body ? "SocialBody" : (socialPosition == Common.SocialPosition.Footer ? "SocialFooter" : "SocialNavigation"); return(View(viewName, viewModel)); }
public async Task <IActionResult> Add(SocialViewModel viewModel) { if (ModelState.IsValid) { viewModel.Name = viewModel.Name.Trim(); var social = _mapper.Map <Social>(viewModel); await _db.SocialRepository.AddAsync(social); await _db.SaveAsync(); return(Redirect("/Admin/Social")); } else { return(View(viewModel)); } }
public void UpdateSocial(SocialViewModel viewModel, Guid id) { Social social = _context.socials.Find(id); if (social != null) { social.Icon = viewModel.Icon; social.Color = viewModel.Color; social.Address = viewModel.Address; social.Name = viewModel.Name; social.IsDelete = false; social.OrderShow = viewModel.OrderShow; social.LastModifyDate = CodeGenerators.GetShamsiDate(); social.LastModifyTime = CodeGenerators.GetCurrentTime(); _context.SaveChanges(); } }
public void AddSocial(SocialViewModel viewModel) { Social social = new Social() { Address = viewModel.Address, Color = viewModel.Color, Icon = viewModel.Icon, Id = CodeGenerators.GetGuid(), IsDelete = false, Name = viewModel.Name, OrderShow = viewModel.OrderShow, LastModifyDate = CodeGenerators.GetShamsiDate(), LastModifyTime = CodeGenerators.GetCurrentTime() }; _context.socials.Add(social); _context.SaveChanges(); }
public ActionResult ProfileView(String name) { if (Session["ID"] != null) { E_Users user = new E_Users(); E_Users result = db.E_Userss.SqlQuery("Select * from E_Users where ID=@p0", name).FirstOrDefault(); SocialViewModel mysocialviewmodel = new SocialViewModel(); mysocialviewmodel.E_users = result; return(View(mysocialviewmodel)); } else { return(RedirectToAction("Login")); } //SocialViewModel socialuser = new SocialViewModel(); //var users = db.E_Userss.SqlQuery("Select * from E_Users where ID = @p0",id).SingleOrDefault(); //socialuser.E_users = users; //return View(socialuser); }
public ActionResult ListPossts() { if (Session["ID"] != null) { S_Post post = new S_Post(); SocialViewModel a = new SocialViewModel(); var id = Session["ID"]; var Posttlist = db.S_Posts.SqlQuery("Select * from S_Post").ToList(); //c = new SocialViewModel(); return(View(Posttlist)); // } } return(View()); }
private bool IsUserFollowUser(string targetUserId) { string token = Request.Cookies["UserToken"].Value; SocialViewModel socialViewModel = new SocialViewModel(); using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://localhost:52536"); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Add("x-token", token); var res = client.PostAsJsonAsync($"api/SocialUser/isUserFollowUser", targetUserId).Result; if (res.IsSuccessStatusCode == true) { return(res.Content.ReadAsAsync <bool>().Result); } else { return(false); } } }
public SignalRClient(SocialViewModel model)//Chat Ctor { this.Model = model; Connection = new HubConnection("http://localhost:51446/signalr"); Hub = Connection.CreateHubProxy("NotificationHub"); Hub.On("GetNotification", (string userId) => { Hub.Invoke("GetNotificationsFromServer", userId); }); Hub.On("GotNotificationsFromServer", (List <NotificationModel> notifications) => { Model.Notifications.Clear(); foreach (var item in notifications) { Model.Notifications.Add(item); //contorller . addNotification{add to notificatin list and notify the view to render} } }); Connection.Start().Wait(); }
public AddMoments() { InitializeComponent(); VM = new SocialViewModel(); BindingContext = VM; }
private async Task <UserViewModel> AutoProvisionUserAsync(string provider, string providerUserId, List <Claim> claims) { // create a list of claims that we want to transfer into our store var filtered = new List <Claim>(); // user's display name var name = claims.FirstOrDefault(x => x.Type == JwtClaimTypes.Name)?.Value ?? claims.FirstOrDefault(x => x.Type == ClaimTypes.Name)?.Value; var username = claims.FirstOrDefault(x => x.Type == "user_name" || x.Type == "username")?.Value ?? claims.FirstOrDefault(x => x.Type == ClaimTypes.Sid)?.Value; if (name != null) { filtered.Add(new Claim(JwtClaimTypes.Name, name)); } else { var first = claims.FirstOrDefault(x => x.Type == JwtClaimTypes.GivenName)?.Value ?? claims.FirstOrDefault(x => x.Type == ClaimTypes.GivenName)?.Value; var last = claims.FirstOrDefault(x => x.Type == JwtClaimTypes.FamilyName)?.Value ?? claims.FirstOrDefault(x => x.Type == ClaimTypes.Surname)?.Value; if (first != null && last != null) { filtered.Add(new Claim(JwtClaimTypes.Name, first + " " + last)); } else if (first != null) { filtered.Add(new Claim(JwtClaimTypes.Name, first)); } else if (last != null) { filtered.Add(new Claim(JwtClaimTypes.Name, last)); } } // email var email = claims.FirstOrDefault(x => x.Type == JwtClaimTypes.Email)?.Value ?? claims.FirstOrDefault(x => x.Type == ClaimTypes.Email)?.Value; if (email != null) { filtered.Add(new Claim(JwtClaimTypes.Email, email)); } //picture var picture = claims.FirstOrDefault(x => x.Type == JwtClaimTypes.Picture)?.Value ?? claims.FirstOrDefault(x => x.Type == "image")?.Value; var user = new SocialViewModel() { Username = username ?? email, Name = name, Email = email, Picture = picture, Provider = provider, ProviderId = providerUserId }; var userExist = await _userAppService.CheckUsername(user.Username) || await _userAppService.CheckEmail(user.Email); if (userExist) { await _userAppService.AddLogin(user); } else { await _userAppService.RegisterWithoutPassword(user); } var claimsFromUser = filtered.Select(f => new SaveUserClaimViewModel() { Type = f.Type, Username = user.Username, Value = f.Value }); foreach (var saveUserClaimViewModel in claimsFromUser) { await _userManageAppService.SaveClaim(saveUserClaimViewModel); } return(await _userManageAppService.FindByProviderAsync(provider, providerUserId)); }
public MomentSendTo(Moment _Moment) { InitializeComponent(); VM = new SocialViewModel(_Moment); BindingContext = VM; }
public Task AddLogin(SocialViewModel model) { var registerCommand = _mapper.Map <AddLoginCommand>(model); return(Bus.SendCommand(registerCommand)); }
public Task RegisterWithoutPassword(SocialViewModel model) { var registerCommand = _mapper.Map <RegisterNewUserWithoutPassCommand>(model); return(Bus.SendCommand(registerCommand)); }