예제 #1
0
 public ActionResult add(FullProfile fullprofile)
 {
     using (MsInUsEntities connection = new MsInUsEntities())
     {
         try
         {
             if (Session["UserName"] != null)
             {
                 fullprofile.Id = Convert.ToInt32(Session["UserId"]);
                 if (fullprofile.Toefl == false)
                 {
                     fullprofile.Ielts = true;
                 }
                 else if (fullprofile.Toefl == null)
                 {
                     fullprofile.Toefl = false;
                 }
                 fullprofile.Ielts         = false;
                 fullprofile.personalScore = getscore(fullprofile);
                 connection.FullProfiles.Add(fullprofile);
                 connection.SaveChanges();
                 Session.Remove("AddProfile");
             }
         }
         catch (System.Data.Entity.Validation.DbEntityValidationException e)
         {
             string msg = e.InnerException.Message;
         }
     }
     return(RedirectToAction("Index", "Home"));
 }
예제 #2
0
        public ActionResult GetProfile(int id)
        {
            FullProfile fs = genConnection.FullProfiles.First(m => m.Id == id);

            fs.admitrejects = genConnection.AdmitsRejects.Where(m => m.StudentId == id).ToList();
            return(View(fs));
        }
예제 #3
0
 public ActionResult edit(FullProfile fullprofile)
 {
     using (MsInUsEntities connection = new MsInUsEntities())
     {
         if (Session["UserName"] != null)
         {
             int         id = Convert.ToInt32(Session["UserId"]);
             FullProfile fp = connection.FullProfiles.Where(m => m.Id == id).FirstOrDefault();
             connection.FullProfiles.Remove(fp);
             connection.SaveChanges();
             if (fullprofile.Toefl == false)
             {
                 fullprofile.Ielts = true;
             }
             if (fullprofile.Toefl == null)
             {
                 fullprofile.Toefl = false; fullprofile.Ielts = false;
             }
             fullprofile.personalScore = getscore(fullprofile);
             connection.FullProfiles.Add(fullprofile);
             connection.SaveChanges();
         }
     }
     return(RedirectToAction("MyProfile", "Profiles"));
 }
        //genertates score for the user
        private decimal?getscore(FullProfile fs)
        {
            decimal paper = 3;
            decimal?score = Convert.ToDecimal(fs.score);

            if (fs.Toefl == true)
            {
                score = score / 120 * 10;
            }
            if (fs.Papers == "Local")
            {
                paper = 6;
            }
            else if (fs.Papers == "National")
            {
                paper = 8;
            }
            else if (fs.Papers == "International")
            {
                paper = 10;
            }
            decimal?total = ((((((fs.GQuant + fs.GVerbal) / 340) * 10) + score + fs.UGScore + ((fs.WorkExperience / 42) * 10) + paper) / 5 * 6) + ((fs.Sop + fs.Lor) / 2 * 3) + ((fs.ExtraCurricular + fs.CommunityService) / 2));

            return(total / 10);
        }
예제 #5
0
        public ActionResult settings()
        {
            MsInUsEntities        connection = new MsInUsEntities();
            List <SelectListItem> year       = new List <SelectListItem>();

            for (int p = DateTime.Today.Year - 40; p < DateTime.Today.Year - 16; p++)
            {
                year.Add(new SelectListItem()
                {
                    Text = Convert.ToString(p), Value = Convert.ToString(p), Selected = (DateTime.Today.Year - 14 == p)
                });
            }
            UserProfile        userprofile = new UserProfile();
            FullProfile        fullprofile = new FullProfile();
            ProfilesController pc          = new ProfilesController();
            int id = Convert.ToInt32(Session["UserId"]);

            userprofile = connection.UserProfiles.Find(keyValues: id);
            if (userprofile.DOB != null)
            {
                userprofile.DOBMonth = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(userprofile.DOB.Value.Month);
                userprofile.DOBYear  = userprofile.DOB.Value.Year;
                userprofile.DOBday   = userprofile.DOB.Value.Day;
            }
            pc.initilization(fullprofile);
            userprofile.FullProfile = fullprofile;
            userprofile.doBirthYear = year;
            return(View(userprofile));
        }
예제 #6
0
 public void initilization(FullProfile fullprofile)
 {
     using (MsInUsEntities dtbase = new MsInUsEntities())
     {
         List <SelectListItem> items = new List <SelectListItem>();
         foreach (var c in dtbase.CourseWorks)
         {
             items.Add(new SelectListItem()
             {
                 Value = c.Course, Text = c.Course
             });
         }
         fullprofile.itemslist = items;
         List <SelectListItem> day = new List <SelectListItem>();
         for (int i = 1; i <= 31; i++)
         {
             day.Add(new SelectListItem()
             {
                 Text = Convert.ToString(i), Value = Convert.ToString(i), Selected = (DateTime.Today.Day == i)
             });
         }
         fullprofile.listday = day;
         List <SelectListItem> year = new List <SelectListItem>();
         for (int p = DateTime.Today.Year - 2; p < DateTime.Today.Year + 6; p++)
         {
             year.Add(new SelectListItem()
             {
                 Text = Convert.ToString(p), Value = Convert.ToString(p), Selected = (DateTime.Today.Year == p)
             });
         }
         fullprofile.listyear = year;
         List <SelectListItem> month = new List <SelectListItem>();
         foreach (var c in System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.MonthGenitiveNames)
         {
             month.Add(new SelectListItem()
             {
                 Text = c, Value = c, Selected = (System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(DateTime.Today.Month) == c)
             });
         }
         fullprofile.listMonth = month;
         List <SelectListItem> papersList = new List <SelectListItem>();
         for (int i = 0; i < papers.Length; i++)
         {
             papersList.Add(new SelectListItem()
             {
                 Text = papers[i], Value = papers[i]
             });
         }
         fullprofile.listpapers = papersList;
         List <SelectListItem> termlist = new List <SelectListItem>();
         for (int i = 0; i < term.Length; i++)
         {
             termlist.Add(new SelectListItem()
             {
                 Text = term[i], Value = term[i]
             });
         }
         fullprofile.listterm = termlist;
     }
 }
예제 #7
0
        public ActionResult edit(int?id)
        {
            id = (id == null) ? Convert.ToInt32(Session["UserId"]) : id;
            FullProfile fullprofiles = new FullProfile();

            fullprofiles = genConnection.FullProfiles.Where(m => m.Id == id).FirstOrDefault();
            initilization(fullprofiles);
            return(View(fullprofiles));
        }
        public ActionResult SimilarProfiles(int?page)
        {
            int                id            = Convert.ToInt32(Session["UserId"]);
            FullProfile        fs            = connection.FullProfiles.First(m => m.Id == id);
            decimal?           actualscore   = fs.personalScore + Convert.ToDecimal(0.3);
            decimal?           negativescore = fs.personalScore - Convert.ToDecimal(0.3);
            List <FullProfile> obj           = connection.FullProfiles.Where(m => (m.personalScore <= actualscore && m.personalScore >= negativescore && m.Id != id)).ToList();

            return(View(obj.ToPagedList(page ?? 1, 8)));
        }
예제 #9
0
        private void CacheProfileJson(FullProfile profile)
        {
            DirectoryInfo dirInfo = Directory.CreateDirectory(Path.Combine(App.ApplicationPath, "players", profile.id));
            string        json    = JsonConvert.SerializeObject(profile, Formatting.Indented);

            using (FileStream fs = File.Create(Path.Combine(dirInfo.FullName, "profile.json")))
                using (StreamWriter sw = new StreamWriter(fs))
                {
                    sw.WriteLine(json);
                }
        }
예제 #10
0
        public ActionResult Myprofile()
        {
            MsInUsEntities dtbase       = new MsInUsEntities();
            FullProfile    fullprofiles = new FullProfile();
            ///initilization(fullprofiles);
            int id = Convert.ToInt32(Session["UserId"]);

            fullprofiles = dtbase.FullProfiles.FirstOrDefault(m => m.Id == id);
            if (dtbase.AdmitsRejects.Any(m => m.StudentId == id))
            {
                fullprofiles.admitrejects = dtbase.AdmitsRejects.Where(m => m.StudentId == id).ToList();
            }
            return(View(fullprofiles));
        }
예제 #11
0
        //this gets profile of the user
        public ActionResult add()
        {
            int userid = Convert.ToInt32(Session["UserId"]);

            if (!genConnection.FullProfiles.Any(m => m.Id == userid))
            {
                if (Session["AddProfile"] != null && Convert.ToBoolean(Session["AddProfile"]) == false)
                {
                    FullProfile fullprofiles = new FullProfile();
                    initilization(fullprofiles);
                    return(View(fullprofiles));
                }
            }
            return(RedirectToAction("MyProfile", "Profiles"));
        }
예제 #12
0
        private async Task RetrieveHead()
        {
            string cachedHead = HeadFromCache(Uid);

            if (cachedHead != null)
            {
                Head = cachedHead;
                return;
            }

            var client   = new HttpClient();
            var uri      = new Uri("https://sessionserver.mojang.com/session/minecraft/profile/" + Uid);
            var response = await client.GetAsync(uri, HttpCompletionOption.ResponseHeadersRead);

            while (response.StatusCode == (HttpStatusCode)429)
            {
                await Task.Delay(5000);

                try
                {
                    response = await client.GetAsync(uri, HttpCompletionOption.ResponseHeadersRead);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Error while retrieving Player Head for " + Name + ": " + e.Message +
                                      ".  Aborting...");
                    return;
                }
            }

            response.EnsureSuccessStatusCode();

            Stream respStream = await response.Content.ReadAsStreamAsync();

            string      fullProfileString = await new StreamReader(respStream).ReadToEndAsync();
            FullProfile fullProfile       = JsonConvert.DeserializeObject <FullProfile>(fullProfileString);

            CacheProfileJson(fullProfile);
            if (fullProfile.properties.Count == 0)
            {
                Head = SetOfflineHead();
            }
            else
            {
                Head = await RetrieveImageFromBase64(fullProfile.properties[0].value);
            }
        }
예제 #13
0
        private string NameFromCache(string uid)
        {
            string path = Path.Combine(App.ApplicationPath, "players", uid, "profile.json");

            if (!File.Exists(path))
            {
                return(null);
            }

            if (File.GetCreationTime(path).AddDays(2) < DateTime.Now)
            {
                return(null);
            }

            FullProfile profile = JsonConvert.DeserializeObject <FullProfile>(File.ReadAllText(path));

            return(profile.name);
        }
        //gets the users profile based on the university, course and status name
        public ActionResult getstatus(int?page, int university, string course, string status)
        {
            int id = Convert.ToInt32(Session["UserId"]);
            List <FullProfile>  fs   = new List <FullProfile>();
            List <AdmitsReject> lobj = connection.AdmitsRejects.Where(m => (m.UnivId == university && m.CourseName == course && m.Status == status)).ToList();

            foreach (AdmitsReject c in lobj)
            {
                FullProfile fsobj = connection.FullProfiles.FirstOrDefault(m => (m.Id == c.StudentId && m.Id != id));
                if (fsobj != null)
                {
                    fsobj.admitrejects = new List <AdmitsReject>();
                    fsobj.admitrejects.Add(c);
                    fs.Add(fsobj);
                }
            }
            return(View("AdmitsRejects", fs.ToPagedList(page ?? 1, 8)));
        }
예제 #15
0
        private async Task RetrieveNameAndHead()
        {
            string cachedName = NameFromCache(Uid);

            if (cachedName != null)
            {
                Name = cachedName;
                return;
            }

            var client   = new HttpClient();
            var uri      = new Uri("https://sessionserver.mojang.com/session/minecraft/profile/" + Uid);
            var response = await client.GetAsync(uri, HttpCompletionOption.ResponseHeadersRead);

            while (response.StatusCode == (HttpStatusCode)429)
            {
                await Task.Delay(5000);

                response = await client.GetAsync(uri, HttpCompletionOption.ResponseHeadersRead);
            }

            //Exception for user not found: Response 204 and 404
            if (response.StatusCode != HttpStatusCode.OK)
            {
                Console.WriteLine("Error while retrieving Mojang data for UUID: " + Uid);
                Name        = Uid;
                OfflineChar = true;
                Head        = SetOfflineHead();
                return;
            }

            Stream respStream = await response.Content.ReadAsStreamAsync();

            string      fullProfileString = await new StreamReader(respStream).ReadToEndAsync();
            FullProfile fullProfile       = JsonConvert.DeserializeObject <FullProfile>(fullProfileString);

            CacheProfileJson(fullProfile);
            Name = fullProfile.name;
            Head = SetOfflineHead();
            if (fullProfile.properties.Count != 0)
            {
                await Task.Run(async() => Head = await RetrieveImageFromBase64(fullProfile.properties[0].value));
            }
        }
        public ActionResult Index()
        {
            int         id = Convert.ToInt32(Session["UserId"]);
            FullProfile fs = connection.FullProfiles.SingleOrDefault(m => m.Id == id);

            if (fs.Toefl == true)
            {
                fs.score = (fs.TIListening + fs.TIReading + fs.TISpeaking + fs.TIWriting).ToString();
            }
            else if (fs.Ielts == true)
            {
                fs.score = ((fs.TIListening + fs.TIReading + fs.TISpeaking + fs.TIWriting) / 4).ToString();
            }
            if (fs.Toefl == null && fs.Ielts == null)
            {
                fs.Toefl = true;
            }
            MsInUsa.Controllers.ProfilesController cobj = new ProfilesController();
            cobj.initilization(fs);
            return(View(fs));
        }
        public async Task <IActionResult> Index()
        {
            FullProfile model = new FullProfile();

            var portfolioHome = from profile in _context.UserProfile
                                join image in _context.ImgUser on profile.IdUser equals image.IdUser
                                where image.IdImg == profile.MainImg

                                select new FullProfile
            {
                IdUser      = profile.IdUser,
                NameUser    = profile.NameUser,
                SurnameUser = profile.SurnameUser,
                CityUser    = profile.AdressUser,
                MainImg     = profile.MainImg,
                IdImg       = image.IdImg,
                ImgUser     = image.DataImg
            };

            model.User = portfolioHome.ToList();
            return(View(model));
        }
        public ActionResult Index(FullProfile fs)
        {
            decimal?score = getscore(fs);

            if (fs.Toefl == true)
            {
                fs.score = (fs.TIListening + fs.TIReading + fs.TISpeaking + fs.TIWriting).ToString();
            }
            else if (fs.Toefl == false)
            {
                fs.score = ((fs.TIListening + fs.TIReading + fs.TISpeaking + fs.TIWriting) / 4).ToString();
            }
            if (fs.Toefl == null && fs.Ielts == null)
            {
                fs.Toefl = true;
            }
            fs.ambUniv  = connection.Universities_list.Where(m => (m.OverallScore >= score + 1 && m.University_Deadlines.Any(c => c.Course == fs.MSCourse))).OrderBy(m => m.OverallScore).Take(5).ToList();
            fs.modUniv  = connection.Universities_list.Where(m => (m.OverallScore > score && m.OverallScore < score + 1 && m.University_Deadlines.Any(c => c.Course == fs.MSCourse))).OrderBy(m => m.OverallScore).Take(5).ToList();
            fs.safeUniv = connection.Universities_list.Where(m => ((m.OverallScore <= score || m.OverallScore == null) && m.University_Deadlines.Any(c => c.Course == fs.MSCourse))).OrderByDescending(m => m.OverallScore).Take(5).ToList();
            MsInUsa.Controllers.ProfilesController cobj = new ProfilesController();
            cobj.initilization(fs);
            return(View("recommend", fs));
        }
        //gets all the profiles whose admits and rejects matches the applied universities of the user
        public ActionResult AdmitsRejects(int?page)
        {
            int id = Convert.ToInt32(Session["UserId"]);
            List <FullProfile>  fs   = new List <FullProfile>();
            List <AdmitsReject> lobj = connection.AdmitsRejects.Where(m => m.StudentId == id).ToList();
            List <AdmitsReject> obj  = new List <AdmitsReject>();

            foreach (var p in lobj)
            {
                obj.AddRange(connection.AdmitsRejects.Where(m => (m.UnivId == p.UnivId && m.CourseId == p.CourseId && m.StudentId != p.StudentId)).ToList());
            }
            foreach (var c in obj)
            {
                FullProfile fobj = new FullProfile();
                fobj = connection.FullProfiles.AsNoTracking().SingleOrDefault(m => (m.Id == c.StudentId && m.Id != id));
                if (fobj != null)
                {
                    fobj.admitrejects = new List <AdmitsReject>();
                    fobj.admitrejects.Add(c);
                    fs.Add(fobj);
                }
            }
            return(View(fs.ToPagedList(page ?? 1, 8)));
        }
예제 #20
0
        private decimal?getscore(FullProfile fs)
        {
            decimal paper = 3;
            decimal?score = 0, quant = 130, verbal = 130, ugscore = 4, workexp = 0;

            if (fs.Toefl == true)
            {
                fs.score = (fs.TIListening + fs.TIReading + fs.TISpeaking + fs.TIWriting).ToString();
            }
            else if (fs.Toefl == false)
            {
                fs.score = ((fs.TIListening + fs.TIReading + fs.TISpeaking + fs.TIWriting) / 4).ToString();
            }
            else
            {
                fs.score = "0";
            }
            if (fs.GQuant != null)
            {
                quant = fs.GQuant;
            }
            if (fs.GVerbal != null)
            {
                verbal = fs.GVerbal;
            }
            if (fs.score != "")
            {
                score = Convert.ToDecimal(fs.score);
            }
            if (fs.Toefl == true)
            {
                score = score / 120 * 10;
            }
            if (fs.UGScore != null)
            {
                ugscore = fs.UGScore;
            }
            if (fs.WorkExperience != null)
            {
                ugscore = fs.UGScore;
            }
            if (fs.WorkExperience != null)
            {
                workexp = fs.WorkExperience;
            }
            if (fs.Papers == "Local")
            {
                paper = 6;
            }
            else if (fs.Papers == "National")
            {
                paper = 8;
            }
            else if (fs.Papers == "International")
            {
                paper = 10;
            }
            decimal?total = ((((((quant + verbal) / 340) * 10) + score + ugscore + ((workexp / 42) * 10) + paper) / 5));

            return(total);
        }
예제 #21
0
 private String showFullProfile(FullProfile fullProfile, bool isCountAnswer, int counter, String HTMLClass)
 {
     String HTML = "";
     String relatedImg = "";
     String relatedName = "";
     String details = "";
     foreach (KeyValuePair<String, Entity[]> key in fullProfile.Details.ToList())
     {
         if (key.Value.Length != 0)
         {
             details += "<tr>"
                     + "<td class=\"property\">"
                         + key.Key
                     + "</td>"
                     + "<td class=\"value expandableContent\">";
             foreach (Entity en in key.Value)
             {
                 details += "<div class=\"line\">";
                 if (en.URI != null)
                     details += "<a href=\"answer.aspx?uri=" + en.URI + "\">" + en.Label + "</a>";
                 else if (en.URI == null && Uri.IsWellFormedUriString(en.Label, UriKind.Absolute))
                     details += "<a href=\"" + en.Label + "\">" + en.Label + "</a>";
                 else
                     details += en.Label;
                 details += "</div>";
             }
         }
     }
     if (fullProfile.Location.Latitude != null & fullProfile.Location.Longitude != null)
         details += "<tr>"
                     + "<td class=\"property\">"
                         + "map"
                     + "</td>"
                     + "<td class=\"value\">"
                         + "<div class=\"line\">"
                             + "<img src=\"http://maps.googleapis.com/maps/api/staticmap?center=" + fullProfile.Location.Latitude + "," + fullProfile.Location.Longitude + "&zoom=11&size=500x200&sensor=false\" title=\"" + "Latitude= " + fullProfile.Location.Latitude + ", Longitude= " + fullProfile.Location.Longitude + "\">"
                         + "</div>";
     details += "</td>"
             + "</tr>";
     foreach (Entity rel in fullProfile.Related.ToList())
         relatedImg += "<td>"
                         + "<div class=\"imgcontainer\">"
                             + "<a href=\"answer.aspx?uri=" + rel.URI + "\">" + "<img src=\"" + rel.Picture + "\"/>" + "</a>"
                         + "</div>"
                     + "</td>";
     foreach (Entity rel in fullProfile.Related.ToList())
         relatedName += "<td class=\"title\">"
                         + "<a href=\"answer.aspx?uri=" + rel.URI + "\">" + rel.Label + "</a>"
                     + "</td>";
     HTML += "<div class=\"fullprofile\">"
             + "<div class=\"abstractcontainer\">";
     if (isCountAnswer)
         HTML += "<div>Number of results=" + counter + "</div>";
     HTML += "<div class=\"profilepic\">"
           + "<img src=\"" + fullProfile.Picture + "\" />"
       + "</div>"
       + "<div class=\"abstract\">"
           + "<a href=\"answer.aspx?uri=" + fullProfile.URI + "\" class=\"title\">" + fullProfile.Label + "</a>"
           + "<p class=\"abstracttext expandableContent\">"
               + fullProfile.Abstract
           + "</p>"
       + "</div>"
       + "<div class=\"clearfix\">"
       + "</div>"
       + "</div>"
       + "<div class=\"relatedresults\">"
       + "<div class=\"subtitle\">"
           + "Related Results</div>"
       + "<table class=\"relateTable\" id=\"headerTable\" runat=\"server\">"
           + "<tr>"
               + relatedImg
           + "</tr>"
           + "<tr>"
               + relatedName
           + "</tr>"
       + "</table>"
       + "</div>"
       + "<div class=\"profiledetails\">"
       + "<div class=\"subtitle\">"
           + "Profile details</div>"
       + "<table class=\"detailstable\">"
           + details
       + "</table>"
       + "</div>"
       + "</div>";
     return HTML;
 }
예제 #22
0
    public async void SetModel(FullProfile profile)
    {
        Profile = profile;
        characterTransitionElement.Leave(false, true);
        characterTransitionElement.enterDuration = 1.2f;
        characterTransitionElement.enterDelay    = 0.4f;
        characterTransitionElement.onEnterStarted.SetListener(() =>
        {
            characterTransitionElement.enterDuration = 0.4f;
            characterTransitionElement.enterDelay    = 0;
        });

        avatar.SetModel(profile.User);
        levelProgressImage.fillAmount = (profile.Exp.TotalExp - profile.Exp.CurrentLevelExp)
                                        / (profile.Exp.NextLevelExp - profile.Exp.CurrentLevelExp);
        uidText.text = profile.User.Uid;

        void MarkOffline()
        {
            statusCircleImage.color = "#757575".ToColor();
            statusText.text         = "PROFILE_STATUS_OFFLINE".Get();
        }

        void MarkOnline()
        {
            statusCircleImage.color = "#47dc47".ToColor();
            statusText.text         = "PROFILE_STATUS_ONLINE".Get();
        }

        if (profile.User.Uid == Context.OnlinePlayer.LastProfile?.User.Uid)
        {
            if (Context.IsOffline())
            {
                MarkOffline();
            }
            else
            {
                MarkOnline();
            }
        }
        else
        {
            if (profile.LastActive == null)
            {
                MarkOffline();
            }
            else
            {
                var lastActive = profile.LastActive.Value.LocalDateTime;
                if (DateTime.Now - lastActive <= TimeSpan.FromMinutes(30))
                {
                    MarkOnline();
                }
                else
                {
                    statusCircleImage.color = "#757575".ToColor();
                    statusText.text         = "PROFILE_STATUS_LAST_SEEN_X".Get(lastActive.Humanize());
                }
            }
        }

        if (profile.Tier == null)
        {
            tierText.transform.parent.gameObject.SetActive(false);
        }
        else
        {
            tierText.transform.parent.gameObject.SetActive(true);
            tierText.text = profile.Tier.name;
            tierGradient.SetGradient(new ColorGradient(profile.Tier.colorPalette.background));
        }
        ratingText.text            = $"{"PROFILE_WIDGET_RATING".Get()} {profile.Rating:0.00}";
        levelText.text             = $"{"PROFILE_WIDGET_LEVEL".Get()} {profile.Exp.CurrentLevel}";
        expText.text               = $"{"PROFILE_WIDGET_EXP".Get()} {(int) profile.Exp.TotalExp}/{(int) profile.Exp.NextLevelExp}";
        totalRankedPlaysText.text  = profile.Activities.TotalRankedPlays.ToString("N0");
        totalClearedNotesText.text = profile.Activities.ClearedNotes.ToString("N0");
        highestMaxComboText.text   = profile.Activities.MaxCombo.ToString("N0");
        avgRankedAccuracyText.text = ((profile.Activities.AverageRankedAccuracy ?? 0) * 100).ToString("0.00") + "%";
        totalRankedScoreText.text  = (profile.Activities.TotalRankedScore ?? 0).ToString("N0");
        totalPlayTimeText.text     = TimeSpan.FromSeconds(profile.Activities.TotalPlayTime)
                                     .Let(it => it.ToString(it.Days > 0 ? @"d\d\ h\h\ m\m\ s\s" : @"h\h\ m\m\ s\s"));

        chartRadioGroup.onSelect.SetListener(type => UpdateChart((ChartType)Enum.Parse(typeof(ChartType), type, true)));
        UpdateChart(ChartType.AvgRating);

        pillRows.ForEach(it => LayoutFixer.Fix(it));
        if (Context.IsOnline())
        {
            var eventBadges = profile.GetEventBadges();
            if (eventBadges.Any())
            {
                badgeGrid.gameObject.SetActive(true);
                badgeGrid.SetModel(eventBadges);
            }
            else
            {
                badgeGrid.gameObject.SetActive(false);
            }
        }

        foreach (Transform child in recordSection.recordCardHolder)
        {
            Destroy(child.gameObject);
        }
        foreach (Transform child in levelSection.levelCardHolder)
        {
            Destroy(child.gameObject);
        }
        foreach (Transform child in collectionSection.collectionCardHolder)
        {
            Destroy(child.gameObject);
        }

        if (profile.RecentRecords.Count > 0)
        {
            recordSection.gameObject.SetActive(true);
            foreach (var record in profile.RecentRecords.Take(6))
            {
                var recordCard = Instantiate(recordCardPrefab, recordSection.recordCardHolder);
                recordCard.SetModel(new RecordView {
                    DisplayOwner = false, Record = record
                });
            }
        }
        else
        {
            recordSection.gameObject.SetActive(false);
        }

        if (profile.LevelCount > 0)
        {
            levelSection.gameObject.SetActive(true);
            foreach (var level in profile.Levels.Take(6))
            {
                var levelCard = Instantiate(levelCardPrefab, levelSection.levelCardHolder);
                levelCard.SetModel(new LevelView {
                    DisplayOwner = false, Level = level.ToLevel(LevelType.User)
                });
            }

            viewAllLevelsButton.GetComponentInChildren <Text>().text = "PROFILE_VIEW_ALL_X".Get(profile.LevelCount);
            viewAllLevelsButton.onPointerClick.SetListener(_ =>
            {
                Context.ScreenManager.ChangeScreen(CommunityLevelSelectionScreen.Id, ScreenTransition.In, 0.4f,
                                                   transitionFocus: ((RectTransform)viewAllLevelsButton.transform).GetScreenSpaceCenter(),
                                                   payload: new CommunityLevelSelectionScreen.Payload
                {
                    Query = new OnlineLevelQuery {
                        owner = profile.User.Uid, category = "all", sort = "creation_date", order = "desc"
                    },
                });
            });
            if (profile.FeaturedLevelCount > 0)
            {
                viewAllFeaturedLevelsButton.gameObject.SetActive(true);
                viewAllFeaturedLevelsButton.GetComponentInChildren <Text>().text =
                    "PROFILE_VIEW_FEATURED_X".Get(profile.FeaturedLevelCount);
                viewAllFeaturedLevelsButton.onPointerClick.SetListener(_ =>
                {
                    Context.ScreenManager.ChangeScreen(CommunityLevelSelectionScreen.Id, ScreenTransition.In, 0.4f,
                                                       transitionFocus: ((RectTransform)viewAllFeaturedLevelsButton.transform).GetScreenSpaceCenter(),
                                                       payload: new CommunityLevelSelectionScreen.Payload
                    {
                        Query = new OnlineLevelQuery {
                            owner = profile.User.Uid, category = "featured", sort = "creation_date", order = "desc"
                        },
                    });
                });
            }
            else
            {
                viewAllFeaturedLevelsButton.gameObject.SetActive(false);
            }

            viewAllLevelsButton.transform.parent.RebuildLayout();
        }
        else
        {
            levelSection.gameObject.SetActive(false);
        }

        if (profile.CollectionCount > 0)
        {
            collectionSection.gameObject.SetActive(true);
            foreach (var collection in profile.Collections.Take(6))
            {
                var collectionCard = Instantiate(collectionCardPrefab, collectionSection.collectionCardHolder);
                collectionCard.SetModel(collection);
            }
        }
        else
        {
            collectionSection.gameObject.SetActive(false);
        }

        LayoutFixer.Fix(sectionParent);

        await UniTask.DelayFrame(5);

        transform.RebuildLayout();

        await UniTask.DelayFrame(0);

        characterTransitionElement.Enter();
    }