public ActionResult EditProfile(ProfileModel model)
        {
            var currentlyLoggedInUserId = (int)Session["UserId"];
            if (!ModelState.IsValid)
            {

                var user = UserRepository.GetUser(currentlyLoggedInUserId);
                model.StatusDropdown = getListForStatusDropdown(user.Status);
                return View(model);
            }
            var userModel = new User();
            userModel.LastName = model.LastName;
            userModel.FirstName = model.FirstName;
            userModel.About = model.About;
            userModel.City = model.City;
            userModel.Weight = model.Weight;
            userModel.Length = model.Length;
            userModel.Quote = model.Quote;
            userModel.Work = model.Work;
            userModel.Status = model.Status;

            UserRepository.UpdateUser(userModel, currentlyLoggedInUserId);

            return RedirectToAction("Profile", "Profile");
        }
        public ActionResult EditProfile()
        {
            var currentlyLoggedInUserId = (int)Session["UserId"];
            var user = UserRepository.GetUser(currentlyLoggedInUserId);

            var profileModel = new ProfileModel();

            profileModel.UserId = user.Id;
            profileModel.Username = user.Username;
            profileModel.Gender = user.Gender;
            profileModel.About = user.About;
            profileModel.Image = user.Image;
            profileModel.age = CountClass.CalculateAge(user.Birthdate);
            profileModel.StatusDropdown = getListForStatusDropdown(user.Status);
            profileModel.FirstName = user.FirstName;
            profileModel.LastName = user.LastName;
            profileModel.City = user.City;
            profileModel.Work = user.Work;
            profileModel.Quote = user.Quote;

            if(user.Length !=null) profileModel.Length = (decimal)user.Length;
            if(user.Weight != null) profileModel.Weight = (decimal)user.Weight;

            return View(profileModel);
        }
        public new ActionResult Profile()
        {
            var model = new ProfileModel();

            model.InjectFrom<UnflatLoopValueInjection>(UserProfile.Current);

            return View(model);
        }
        public string get_profiled_Name(ProfileModel model)
        {
            _profile.Push("table");

            _document.Model = model;

            return _document.Show(x => x.Name).ToString();
        }
Exemple #5
0
        public static void ClearUserCache(ProfileModel user)
        {
            DataClassesDataContext db = new DataClassesDataContext();
            var query = from g in db.walk_logs
                        where g.log_user == user.UserCtx.user_id &&
                              g.updated_at < user.UserCtx.hv_last_sync_time
                        select g;

            foreach (var info in query)
            {
                db.walk_logs.DeleteOnSubmit(info);
            }

            db.SubmitChanges();
        }
 public ActionResult PostWallMessage(ProfileModel model,int ReciverID)
 {
     var currentlyLoggedInUserId = (int)Session["UserId"];
     if (!ModelState.IsValid)
     {
         return View(model);
     }
     var wall = new Wall();
     wall.Date = DateTime.Now;
     wall.ReciverID = ReciverID;
     wall.TheMessage = model.wallMessage;
     wall.SenderID = currentlyLoggedInUserId;
     WallRepository.postWallMessage(wall);
     return RedirectToAction("VisitProfile", "Profile",new {userid=ReciverID});
 }
        private ProfileModel makeProfile(Dictionary<string, string> profileOptions, NetInterfaceModel netInterface)
        {
            String profileName =
                Encoding.UTF8.GetString(ibm852enc.GetBytes(profileOptions["Nazwa"]));

            ProfileModel profile = new ProfileModel(profileName, netInterface);
            profile.PhysicalAddress = profileOptions["Adres fizyczny"];
            profile.GUID = profileOptions["Identyfikator GUID"];

            // TODO: tylko jak jest połączony
            //profile.Signal = profileOptions[profileOptions.Keys.Where(x => x.StartsWith("Sygn")).ToList()[0]];
            //profile.SSID = profileOptions["SSID"];
            //profile.Authentication = profileOptions["Uwierzytelnianie"];

            //Profile profile = new Profile(profileOptions["Name"]);
            //profile.PhysicalAddress = profileOptions["Physical address"];
            //profile.GUID = profileOptions["GUID"];
            //profile.Authentication = profileOptions["Authentication"];
            //profile.BSSID = profileOptions["BSSID"];
            //profile.Channel = profileOptions["Channel"];
            //profile.Cipher = profileOptions["Cipher"];
            //profile.ConnectionMode = profileOptions["Connection mode"];
            //profile.Description = profileOptions["Description"];
            //profile.NetworkType = profileOptions["Network type"];
            //profile.ProfileName = profileOptions["Profile"];
            //profile.RadioType = profileOptions["Radio type"];
            //profile.ReceiveRate = profileOptions["Receive rate (Mbps)"];
            //profile.Signal = profileOptions["Signal"];
            //profile.SSID = profileOptions["SSID"];
            //profile.State = profileOptions["State"];
            //profile.TransmitRate = profileOptions["Transmit rate (Mbps)"];

            //profile.BSSID = profileOptions["BSSID"];
            //profile.Channel = profileOptions["Channel"];
            //profile.Cipher = profileOptions["Cipher"];
            //profile.ConnectionMode = profileOptions["Connection mode"];
            //profile.Description = profileOptions["Description"];
            //profile.NetworkType = profileOptions["Network type"];
            //profile.ProfileName = profileOptions["Profile"];
            //profile.RadioType = profileOptions["Radio type"];
            //profile.ReceiveRate = profileOptions["Receive rate (Mbps)"];

            //profile.State = profileOptions["State"];
            //profile.TransmitRate = profileOptions["Transmit rate (Mbps)"];

            return profile;
        }
        public new ActionResult Profile(ProfileModel model)
        {
            if (ModelState.IsValid)
            {
                UserProfile.Current.InjectFrom<UnflatLoopValueInjection>(model);

                try
                {
                    var result = _userService.SaveOrUpdate(UserProfile.Current);

                    if (ModelState.Process(result))
                    {
                        TempData.AddSuccessMessage("User was successfully updated.");
                        return RedirectToAction("Profile");
                    }
                }
                catch (Exception)
                {
                    ModelState.AddModelError("Exception", "Unexpected error");
                }
            }

            return View(model);
        }
        public IActionResult EditProfile()
        {
            var model = new ProfileModel();

            return(View(model));
        }
Exemple #10
0
        /// <inheritdoc/>
        public async Task CreateOrUpdateProfile(string name, Guid clientId, string clientSecret)
        {
            var profileModel = new ProfileModel(name, clientId, clientSecret);

            await CreateOrUpdateProfile(profileModel);
        }
Exemple #11
0
        public new ActionResult Profile()
        {
            var profile = new ProfileModel();

            using (var db = new Context())
            {
                var user = db.UserRoles.First(sh => sh.username.Contains(User.Identity.Name));
                profile.ID       = user.ID;
                profile.username = user.username;
                switch (user.role)
                {
                case "dim":
                    try
                    {
                        var un = db.UnitMembers.First(sh => sh.Username == user.username);
                        profile.membership = db.Units.First(sh => sh.ID == un.ClassID).name;
                        profile.insitute   = db.Units.First(sh => sh.ID == un.ClassID).institute;
                        profile.count      = db.Publishments.Where(sh => sh.uploadedby == user.ID).ToList().Count;
                        profile.role       = "Δημοσιεύον";
                    }
                    catch (Exception e)
                    {
                        profile.membership = "Δεν ανήκετε σε κάποια μονάδα";
                        profile.insitute   = "-";
                        profile.count      = db.Publishments.Where(sh => sh.uploadedby == user.ID).ToList().Count;
                        profile.role       = "Δημοσιέυον";
                    }

                    break;

                case "yp":
                    try
                    {
                        var um = db.UnitMasters.First(sh => sh.MasterID.Contains(user.username));
                        profile.membership = db.Units.First(sh => sh.ID == um.UnitID).name;
                        profile.insitute   = db.Units.First(sh => sh.ID == um.UnitID).institute;
                        profile.role       = "Υπεύθυνος";
                        profile.count      = db.Publishments.Where(sh => sh.uploadedby == user.ID).ToList().Count;
                    }
                    catch (Exception e)
                    {
                        profile.membership = "Η μονάδα δεν είναι πλέον διαθέσιμη";
                    }
                    break;
                }

                try
                {
                    profile.choises = new List <string>();
                    var writer = db.Writers.First(sh => sh.ID == user.ID);
                    profile.writername       = writer.name;
                    profile.writersurrname   = writer.surrname;
                    profile.writerorchidurl  = writer.orchidURL;
                    profile.writerprivateurl = writer.privateURL;
                    profile.writerproperty   = writer.property;
                }
                catch (Exception e)
                {
                    //if user not register as a writer return an empty form to complete
                    profile.writername       = "";
                    profile.writersurrname   = "";
                    profile.writerorchidurl  = "";
                    profile.writerprivateurl = "";
                    profile.writerproperty   = "";
                }

                profile.choises.Add("Τεχνικό Προσωπικό");
                profile.choises.Add("Καθηγητής");
                profile.choises.Add("Ερευνητής");
                profile.choises.Add("Ερευνητικό Προσωπικό");
                profile.avaliableUnits = db.Units.ToList();
            }


            return(View(profile));
        }
 public async Task <ActionResult> CreateProfile(ProfileModel model)
 {
     if (ModelState.IsValid)
     {
         var path = AppDomain.CurrentDomain.BaseDirectory;
         var file = new BinaryFile();
         if (model.Photo != null)
         {
             file = new BinaryFile
             {
                 Name        = DateTime.Now.ToString().Replace("/", "_").Replace(":", "_") + model.Photo.FileName,
                 Path        = Path.Combine(path, @"App_Data\Files", DateTime.Now.ToString().Replace("/", "_").Replace(":", "_") + model.Photo.FileName),
                 ContentType = model.Photo.ContentType
             };
             if (!Directory.Exists(file.Path))
             {
                 Directory.CreateDirectory(Path.Combine(path, @"App_Data\Files"));
             }
             using (var fileStream = System.IO.File.Create(file.Path))
             {
                 model.Photo.InputStream.Seek(0, System.IO.SeekOrigin.Begin);
                 model.Photo.InputStream.CopyTo(fileStream);
             }
             fileRepository.Save(file);
         }
         List <long> IdList = new List <long>();
         if (model.NewExperience != null)
         {
             IdList.AddRange(experienceRepository.CreateNewExperience(model.NewExperience));
         }
         if (model.NewExperience == null && model.SelectedExperience == null)
         {
             IdList.AddRange(experienceRepository.CreateNewExperience("Без опыта"));
         }
         if (model.SelectedExperience != null)
         {
             foreach (var e in model.SelectedExperience)
             {
                 IdList.Add(Convert.ToInt64(e));
             }
         }
         Candidate candidate = new Candidate
         {
             DateofBirth = model.DateOfBirth,
             Name        = model.Name,
             Experience  = experienceRepository.GetSelectedExperience(IdList),
             User        = UserManager.FindById(Convert.ToInt64(User.Identity.GetUserId())),
             Avatar      = file
         };
         try
         {
             jobseekerRepository.Save(candidate);
             return(RedirectToAction("Main", "Jobseeker"));
         }
         catch
         {
             //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Record Inserted Successfully')", true);
             return(RedirectToAction("Main", "Jobseeker"));
         }
     }
     return(RedirectToAction("Main", "Jobseeker")); //добавить оповещения
 }
Exemple #13
0
        public static walk_log PopulateWalkLogFromHV(walk_log entity,
            AerobicSession aerobics, ProfileModel profile)
        {
            entity.log_user = profile.UserCtx.user_id;
            //TODO: obtain weight from HV when the steps were recorded
            entity.log_weight = profile.UserCtx.user_weight;
            entity.log_date = aerobics.When.ToDateTime();
            entity.log_steps = aerobics.Session.NumberOfSteps;
            entity.log_aerobicsteps = aerobics.Session.NumberOfAerobicSteps;

            if (aerobics.Session.Distance != null)
            {
                entity.log_distance = aerobics.Session.Distance.Meters / 1609.344;
            }
            else
            {
                // Get distance from steps
                entity.log_distance = DataConversion.GetDistanceFromSteps(
                    profile.UserCtx.user_stride,
                    aerobics.Session.NumberOfSteps.Value);
            }

            if (aerobics.Session.Energy.HasValue)
            {
                entity.log_calories = aerobics.Session.Energy;
            }
            else
            {
                // Get energy from steps
                entity.log_calories = DataConversion.GetEnergyFromSteps(
                    profile.UserCtx.user_stride,
                    profile.UserCtx.user_weight,
                    aerobics.Session.NumberOfSteps.Value);
            }
            entity.hv_item_id = aerobics.Key.Id;
            entity.updated_at = DateTime.Now;
            return entity;
        }
        private void ForumThreads(int createdByUserId, ProfileModel model)
        {
            const int forumThreadsToDisplay = 5;

            using (var context = new DasKlubDbContext())
            {
                List<ForumSubCategory> mostRecentThreads =
                    (from thread in context.ForumSubCategory
                     where thread.CreatedByUserID == createdByUserId
                        orderby thread.CreateDate descending
                     select thread)
                        .Take(forumThreadsToDisplay)
                        .ToList();

                DbCommand command = DbAct.CreateCommand();
                command.CommandText = string.Format(@"
                    SELECT TOP {0} [ForumSubCategoryID], [CreateDate]
                    FROM
                    (
                        SELECT [ForumSubCategoryID]
                              ,[CreateDate]
                              ,ROW_NUMBER() OVER (PARTITION BY [ForumSubCategoryID]
                        ORDER BY [CreateDate] DESC) AS Seq
                        FROM  [ForumPosts]
                        WHERE createdByUserId = {1}
                    ) PartitionedTable
                    WHERE PartitionedTable.Seq = 1
                    ORDER BY [CreateDate] DESC ", forumThreadsToDisplay, createdByUserId);
                command.CommandType = CommandType.Text;
                DataTable mostRecentPostsToThreads = DbAct.ExecuteSelectCommand(command);
                var mostRecentPostsToThreadsList = new List<ForumSubCategory>();

                foreach (DataRow item in mostRecentPostsToThreads.Rows)
                {
                    mostRecentPostsToThreadsList.Add
                        (
                            new ForumSubCategory
                            {
                                CreateDate = Convert.ToDateTime(item["CreateDate"]),
                                ForumSubCategoryID = Convert.ToInt32(item["ForumSubCategoryID"])
                            }
                        );
                }

                var finalThreadList = mostRecentThreads.ToDictionary(
                                            thread => thread.ForumSubCategoryID,
                                            thread => thread.CreateDate);

                foreach (var thread in mostRecentPostsToThreadsList)
                {
                    if (finalThreadList.ContainsKey(thread.ForumSubCategoryID))
                        finalThreadList[thread.ForumSubCategoryID] = thread.CreateDate;
                    // updates to more recent date, last post
                    else
                        finalThreadList.Add(thread.ForumSubCategoryID, thread.CreateDate);
                }

                var recentThreadIds =
                    finalThreadList.OrderByDescending(x => x.Value)
                        .Select(x => x.Key)
                        .Take(forumThreadsToDisplay)
                        .ToList();

                model.ForumPostUrls = new List<ForumSubCategory>();

                foreach (var threadId in recentThreadIds)
                {
                    var thread =
                        context.ForumSubCategory.First(x => x.ForumSubCategoryID == threadId);
                    var forum =
                        context.ForumCategory.First(x => x.ForumCategoryID == thread.ForumCategoryID);
                    thread.ForumCategory = forum;
                    model.ForumPostUrls.Add(thread);
                }
            }
        }
Exemple #15
0
 public static string GetProfileUrl(this UrlHelper helper, ProfileModel member)
 {
     return("/members/" + (member.HasGitHubUsername ? member.GitHubUsername : "******" + member.Id) + "/");
 }
Exemple #16
0
 public void UpdateProfile(ProfileModel profile)
 {
     _profileUOW.Profiles.Update(profile);
     _profileUOW.Save();
 }
Exemple #17
0
 public void CreateProfile(ProfileModel profile)
 {
     _profileUOW.Profiles.Create(profile);
     _profileUOW.Save();
 }
Exemple #18
0
 internal EditProfileName(Window owner, ProfileModel model) : this()
 {
     this.Owner        = owner;
     this.DataContext  = model;
     this._displayName = model.DisplayName;
 }
Exemple #19
0
        private static void ProcessStepsHealthItem(HealthRecordItem item, ProfileModel profile)
        {
            if (item.TypeId.Equals(AerobicSession.TypeId))
            {
                AerobicSession aerobic = (AerobicSession)item;

                // Only add items with Steps
                if (aerobic.Session.NumberOfSteps > 0)
                {

                    // Is Step in Cache ?
                    DataClassesDataContext db = new DataClassesDataContext();
                    var query = (from g in db.walk_logs
                                 where ((g.log_user == profile.UserCtx.user_id) &&
                                       (g.hv_item_id == item.Key.Id))
                                 select g).SingleOrDefault();
                    // Update or Insert?
                    if (query != null)
                    {
                        query =
                            PopulateWalkLogFromHV(
                                query, aerobic, profile);
                        db.SubmitChanges();
                    }
                    else
                    {
                        walk_log entity = new walk_log();
                        entity = PopulateWalkLogFromHV(
                            entity, aerobic, profile);
                        WalkLogModel.Insert(entity);
                    }
                }

            }
            else if (item.TypeId.Equals(Exercise.TypeId))
            {
                Exercise exercise = (Exercise)item;

                // Only add items with Steps
                double numberOfSteps = 0;
                try
                {
                    numberOfSteps =
                        exercise.Details[ExerciseDetail.Steps_count].Value.Value;
                }
                catch
                {
                    WlkMiTracer.Instance.Log("HVSync.cs:ProcessStepsHealthItem", WlkMiEvent.AppDomain, WlkMiCat.Warning,
                        string.Format("UserId {0} has no pedometer data in HV item", profile.UserCtx.user_id));
                    return;
                }

                if (numberOfSteps > 0)
                {

                    // Is Step in Cache ?
                    DataClassesDataContext db = new DataClassesDataContext();
                    var query = (from g in db.walk_logs
                                 where ((g.log_user == profile.UserCtx.user_id) &&
                                       (g.hv_item_id == item.Key.Id))
                                 select g).SingleOrDefault();
                    // Update or Insert?
                    if (query != null)
                    {
                        query =
                            PopulateWalkLogFromHV(
                                query, exercise, profile);
                        db.SubmitChanges();
                    }
                    else
                    {
                        walk_log entity = new walk_log();
                        entity = PopulateWalkLogFromHV(
                            entity, exercise, profile);
                        WalkLogModel.Insert(entity);
                    }
                }
            }
        }
Exemple #20
0
        /// <summary>
        /// Create a new step to HealthVault
        /// </summary>
        public static bool SaveStepsToHV(PersonInfo info, DateTime dateRecorded,
            long steps, ProfileModel profile)
        {
            ApproximateDateTime hvDate = new ApproximateDateTime(
                new ApproximateDate(dateRecorded.Year, dateRecorded.Month, dateRecorded.Day),
                new ApproximateTime(
                    dateRecorded.Hour, dateRecorded.Minute, dateRecorded.Second));

            Exercise newData = new Exercise(hvDate,
                new CodableValue("walk", new CodedValue("walk", "aerobic-activities")));

            newData.Details.Add(ExerciseDetail.Steps_count,
                new ExerciseDetail(new CodedValue(ExerciseDetail.Steps_count, "exercise-detail-names"),
                    new StructuredMeasurement(
                        (double)steps,
                        new CodableValue("Count", new CodedValue("Count", "exercise-units")))));

            if (profile.UserCtx.user_stride > 0)
            {
                double? distance = DataConversion.GetDistanceFromSteps(profile.UserCtx.user_stride,
                    steps);
                if (distance.HasValue && distance.Value > 0)
                {
                    newData.Distance = new Length(DataConversion.ConvertMilesToMeters(distance.Value));
                }

                if (profile.UserCtx.user_weight > 0)
                {
                    newData.Details.Add(ExerciseDetail.CaloriesBurned_calories,
                        new ExerciseDetail(new CodedValue(ExerciseDetail.CaloriesBurned_calories, "exercise-detail-names"),
                            new StructuredMeasurement(
                                DataConversion.GetEnergyFromSteps(profile.UserCtx.user_stride,
                                profile.UserCtx.user_weight, (int)steps).Value,
                                new CodableValue("Calories", new CodedValue("Calories", "exercise-units")))
                        ));
                }
            }
            info.SelectedRecord.NewItem(newData);
            return true; //Success
        }
Exemple #21
0
        /// <summary>
        /// Create a new miles to HealthVault
        /// </summary>
        public static bool SaveMilesToHV(PersonInfo info, DateTime dateRecorded,
            double distance, ProfileModel profile)
        {
            ApproximateDateTime hvDate = new ApproximateDateTime(
                new ApproximateDate(dateRecorded.Year, dateRecorded.Month, dateRecorded.Day),
                new ApproximateTime(
                    dateRecorded.Hour, dateRecorded.Minute, dateRecorded.Second));

            Exercise newData = new Exercise((ApproximateDateTime)hvDate,
                new CodableValue("walk", new CodedValue("walk", "aerobic-activities")));

            DisplayValue hvDisplay = new DisplayValue(distance, "Miles");

            //convert miles into meters
            if (distance > 0)
            {
                newData.Distance = new Length(DataConversion.ConvertMilesToMeters(distance),
                    hvDisplay);
            }

            if (profile.UserCtx.user_stride > 0)
                newData.Details.Add(ExerciseDetail.Steps_count,
                    new ExerciseDetail(new CodedValue(ExerciseDetail.Steps_count, "exercise-detail-names"),
                        new StructuredMeasurement(
                            DataConversion.GetStepsFromDistanceAndStride(distance, profile.UserCtx.user_stride),
                            new CodableValue("Count", new CodedValue("Count", "exercise-units")))));

            if (profile.UserCtx.user_weight > 0)
                newData.Details.Add(ExerciseDetail.CaloriesBurned_calories,
                    new ExerciseDetail(new CodedValue(ExerciseDetail.CaloriesBurned_calories, "exercise-detail-names"),
                        new StructuredMeasurement(
                            DataConversion.GetEnergyFromDistanceAndWeightNotNullable(distance, profile.UserCtx.user_weight),
                            new CodableValue("Calories", new CodedValue("Calories", "exercise-units")))
                            ));

            info.SelectedRecord.NewItem(newData);
            return true; //Success
        }
Exemple #22
0
        public static walk_log PopulateWalkLogFromHV(walk_log entity,
            Exercise exercise, ProfileModel profile)
        {
            entity.log_user = profile.UserCtx.user_id;

            //TODO: obtain weight from HV when the steps were recorded
            entity.log_weight = profile.UserCtx.user_weight;

            entity.log_date = new DateTime(
                exercise.When.ApproximateDate.Year,
                exercise.When.ApproximateDate.Month.HasValue ?
                    exercise.When.ApproximateDate.Month.Value : 1,
                exercise.When.ApproximateDate.Day.HasValue ?
                    exercise.When.ApproximateDate.Day.Value : 1,
                exercise.When.ApproximateTime.Hour,
                exercise.When.ApproximateTime.Minute,
                exercise.When.ApproximateTime.Second.HasValue ?
                    exercise.When.ApproximateTime.Second.Value : 1);

            long steps = (long)exercise.Details[ExerciseDetail.Steps_count].Value.Value;
            entity.log_steps = steps;

            int aerobicSteps = 0;
            try
            {
                aerobicSteps = (int)exercise.Details[ExerciseDetail.AerobicSteps_count].Value.Value;
            }
            catch
            {
                // eat
            }
            entity.log_aerobicsteps = aerobicSteps;

            if (exercise.Distance != null)
            {
                entity.log_distance = DataConversion.ConvertMetersToMiles(
                    exercise.Distance.Meters);
            }
            else
            {
                // Get distance from steps
                entity.log_distance = DataConversion.GetDistanceFromSteps(
                    profile.UserCtx.user_stride,
                    steps);
            }

            double? calories = null;
            try
            {
                calories =
                    exercise.Details[ExerciseDetail.CaloriesBurned_calories].Value.Value;
            }
            catch
            {
                // eat calorie errors
            }
            if (calories.HasValue)
            {
                entity.log_calories = calories.Value;
            }
            else
            {
                // Get energy from steps
                entity.log_calories = DataConversion.GetEnergyFromSteps(
                    profile.UserCtx.user_stride,
                    profile.UserCtx.user_weight,
                    steps);
            }
            entity.hv_item_id = exercise.Key.Id;
            entity.updated_at = DateTime.Now;
            return entity;
        }
Exemple #23
0
        /// <summary>
        ///     Exports the given profile to the provided path in XML
        /// </summary>
        /// <param name="prof">The profile to export</param>
        /// <param name="path">The path to save the profile to</param>
        public static void ExportProfile(ProfileModel prof, string path)
        {
            var json = JsonConvert.SerializeObject(prof);

            File.WriteAllText(path, json);
        }
        public JsonResult ProfilePagina(int page, int tamPag, string order)
        {
            var lista = ProfileModel.RecoverList(page, tamPag, order: order);

            return(Json(lista));
        }
 public ProfileModel UpdateMyProfile(ProfileModel profile)
 {
     return(_profileService.UpdateMyProfile(profile));
 }
Exemple #26
0
 private void MapEntityToModel(User entity, ProfileModel model)
 {
     model.RegistrationDate = entity.Created;
 }
Exemple #27
0
 async Task IEventHandler <UserSignedOut> .HandleAsync(UserSignedOut payload)
 {
     profile = null;
     await localStorage.DeleteAsync();
 }
        private void GetUserNews(ProfileModel model)
        {
            var conts = new Contents();

            conts.GetContentForUser(_ua.UserAccountID);

            var userNews = new List<Content>();

            foreach(var newsItem in conts)
            {
                if (newsItem.IsLive) userNews.Add(newsItem);
            }

            model.NewsCount = userNews.Count;

            if (userNews.Count > 0)
            {
                userNews.Sort((x, y) => (y.ReleaseDate.CompareTo(x.ReleaseDate)));

                var displayContents = new Contents();
                const int maxCont = 1;
                int currentCount = 0;

                foreach (Content ccn1 in userNews)
                {
                    if (maxCont > currentCount)
                    {
                        if (ccn1.ReleaseDate >= DateTime.UtcNow) continue;

                        currentCount++;
                        displayContents.Add(ccn1);
                    }
                    else break;
                }

                displayContents.IncludeStartAndEndTags = false;

                model.NewsArticles = displayContents.ToUnorderdList;
            }
        }
Exemple #29
0
 private static bool ValidateProfile(ProfileModel profile)
 {
     return(true);
 }
Exemple #30
0
        /// <summary>
        /// Updates the user.
        /// </summary>
        /// <param name="storefront">The storefront.</param>
        /// <param name="visitorContext">The visitor context.</param>
        /// <param name="inputModel">The input model.</param>
        /// <returns>
        /// The manager response where the user is returned.
        /// </returns>
        public virtual ManagerResponse <UpdateUserResult, CommerceUser> UpdateUser([NotNull] CommerceStorefront storefront, [NotNull] VisitorContext visitorContext, ProfileModel inputModel)
        {
            Assert.ArgumentNotNull(storefront, "storefront");
            Assert.ArgumentNotNull(visitorContext, "visitorContext");
            Assert.ArgumentNotNull(inputModel, "inputModel");

            UpdateUserResult result;

            var userName     = visitorContext.UserName;
            var commerceUser = this.GetUser(userName).Result;

            if (commerceUser != null)
            {
                commerceUser.FirstName = inputModel.FirstName;
                commerceUser.LastName  = inputModel.LastName;
                commerceUser.Email     = inputModel.Email;
                commerceUser.SetPropertyValue("Phone", inputModel.TelephoneNumber);

                try
                {
                    var request = new UpdateUserRequest(commerceUser);
                    result = this.CustomerServiceProvider.UpdateUser(request);
                }
                catch (Exception ex)
                {
                    result = new UpdateUserResult {
                        Success = false
                    };
                    result.SystemMessages.Add(new Sitecore.Commerce.Services.SystemMessage {
                        Message = ex.Message + "/" + ex.StackTrace
                    });
                }
            }
            else
            {
                // user is authenticated, but not in the CommerceUsers domain - probably here because we are in edit or preview mode
                var message = StorefrontManager.GetSystemMessage(StorefrontConstants.SystemMessages.UpdateUserProfileError);
                message = string.Format(CultureInfo.InvariantCulture, message, Context.User.LocalName);
                result  = new UpdateUserResult {
                    Success = false
                };

                result.SystemMessages.Add(new Commerce.Services.SystemMessage {
                    Message = message
                });
            }

            if (!result.Success)
            {
                Helpers.LogSystemMessages(result.SystemMessages, result);
            }

            return(new ManagerResponse <UpdateUserResult, CommerceUser>(result, result.CommerceUser));
        }
 /// <summary>
 /// Add a tower to the list of UnlockedTowers
 /// </summary>
 /// <param name="profileModel"></param>
 /// <param name="towerId">The ID of the tower you want to unlock</param>
 public static void UnlockTower(this ProfileModel profileModel, string towerId)
 {
     profileModel.unlockedTowers.Add(towerId);
 }
Exemple #32
0
 public Task <EditUserResult> ChangeData(ProfileModel model)
 => _httpClient.PostJsonAsync <EditUserResult>("api/EditProfile/edit", model);
Exemple #33
0
        /// <summary>
        /// Updates the currently logged in members profile
        /// </summary>
        /// <param name="model"></param>
        /// <returns>
        /// The updated MembershipUser object
        /// </returns>
        public virtual Attempt <MembershipUser> UpdateMemberProfile(ProfileModel model)
        {
            if (IsLoggedIn() == false)
            {
                throw new NotSupportedException("No member is currently logged in");
            }

            //get the current membership user
            var provider       = _membershipProvider;
            var membershipUser = provider.GetCurrentUser();

            //NOTE: This should never happen since they are logged in
            if (membershipUser == null)
            {
                throw new InvalidOperationException("Could not find member with username " + _httpContext.User.Identity.Name);
            }

            try
            {
                //check if the email needs to change
                if (model.Email.InvariantEquals(membershipUser.Email) == false)
                {
                    //Use the membership provider to change the email since that is configured to do the checks to check for unique emails if that is configured.
                    var requiresUpdating = UpdateMember(membershipUser, provider, model.Email);
                    membershipUser = requiresUpdating.Result;
                }
            }
            catch (Exception ex)
            {
                //This will occur if an email already exists!
                return(Attempt <MembershipUser> .Fail(ex));
            }

            var member = GetCurrentPersistedMember();

            //NOTE: If changing the username is a requirement, than that needs to be done via the IMember directly since MembershipProvider's natively do
            // not support changing a username!
            if (model.Name != null && member.Name != model.Name)
            {
                member.Name = model.Name;
            }

            if (model.MemberProperties != null)
            {
                foreach (var property in model.MemberProperties
                         //ensure the property they are posting exists
                         .Where(p => member.ContentType.PropertyTypeExists(p.Alias))
                         .Where(property => member.Properties.Contains(property.Alias))
                         //needs to be editable
                         .Where(p => member.ContentType.MemberCanEditProperty(p.Alias)))
                {
                    member.Properties[property.Alias].Value = property.Value;
                }
            }

            _applicationContext.Services.MemberService.Save(member);

            //reset the FormsAuth cookie since the username might have changed
            FormsAuthentication.SetAuthCookie(member.Username, true);

            return(Attempt <MembershipUser> .Succeed(membershipUser));
        }
Exemple #34
0
        public static bool IsProfileUnique(ProfileModel profileModel)
        {
            var existing = ReadProfiles(profileModel.KeyboardSlug + "/" + profileModel.GameName);

            return(!existing.Contains(profileModel));
        }
 public PostLikeModelId(PostModel post, ProfileModel profile)
     : this(post.Id, profile.Id)
 {
 }
Exemple #36
0
        public ActionResult UserProfile([Bind(Include = "Id,BookingID,Name,Surname,IdentityNumber,Address,CellNo,Date,Clerk,Technician,JobCard,Title,Country,Province,AreaCode,DateOfBirth,Model,SerialNo,Signature,Email,DeviceName,type,datein,dateout,status")] ProfileModel model)
        {
            TempData.Keep();

            if (ModelState.IsValid)
            {
                var booking = new ProfileModel();


                booking.datein         = model.datein;
                booking.dateout        = model.Date;
                booking.SerialNo       = model.SerialNo;
                booking.Email          = model.Email;
                booking.DeviceName     = model.DeviceName;
                booking.status         = model.status;
                booking.type           = model.type;
                booking.JobCard        = model.JobCard;
                booking.Name           = model.Name;
                booking.Surname        = model.Surname;
                booking.IdentityNumber = model.IdentityNumber;
                booking.JobCard        = model.JobCard;
                booking.CellNo         = model.CellNo;
                booking.Address        = model.Address;
                booking.Country        = model.Country;
                booking.Address        = model.Address;
                booking.AreaCode       = model.AreaCode;
                booking.Date           = model.Date;
                booking.Email          = model.Email;
                booking.Province       = model.Province;
                booking.Title          = model.Title;
                booking.DateOfBirth    = model.DateOfBirth;
                booking.Id             = User.Identity.GetUserId();



                Session["Name"]     = model.Name;
                TempData["Surname"] = model.Surname;

                TempData["JobCard"]       = model.JobCard;
                Session["IdentityNumber"] = model.IdentityNumber;
                TempData["CellNo"]        = model.CellNo;
                TempData["Address"]       = model.Address;

                TempData["Country"] = model.Country;

                TempData["AreaCode"]    = model.AreaCode;
                TempData["Province"]    = model.Province;
                TempData["Email"]       = model.Email;
                TempData["Date"]        = model.Surname;
                TempData["DateOfBirth"] = model.Name;
                TempData["Surname"]     = model.Surname;
                TempData["UserID"]      = model.Id;



                db.Profiles.Add(booking);
                db.SaveChanges();

                return(View());
            }
            return(View(model));
        }
Exemple #37
0
 private void SetProfile(ProfileModel profileModel)
 {
     _profileModel = profileModel ?? throw new ArgumentNullException(nameof(profileModel));
     UpdateGui();
 }
Exemple #38
0
 public User(PlayStationClient client, ProfileModel profile) : this()
 {
     Init(client, profile);
 }
Exemple #39
0
        public static void OfflineSyncUser(ProfileModel profile)
        {
            DateTime timeStamp = DateTime.Now;

            // Retrieve the latest info from HealthVault
            if (profile.UserCtx.hv_personid != null)
            {
                HealthRecordItemCollection items = GetHVItemsOffline(profile.UserCtx.hv_personid,
                    profile.UserCtx.hv_recordid, profile.UserCtx.hv_last_sync_time);
                if (items != null && items.Count > 0)
                {
                    foreach (HealthRecordItem item in items)
                    {
                        // Do the distinct per item work
                        ProcessStepsHealthItem(item, profile);
                    }
                    WlkMiTracer.Instance.Log("HVSync.cs:OfflineSyncUser", WlkMiEvent.AppSync,
                        WlkMiCat.Info, string.Format("Number of items retrieved from HV: {0}",
                        items.Count));
                }
                //only update the last sync time if we are able to download items
                if (items != null)
                {
                    //set last sync time
                    profile.UserCtx.hv_last_sync_time = timeStamp;
                    profile.Save();
                }
            }

            // Clear the WlkMi data cache if the last sync is null
            // In other words, you can also set the time stamp for user's last sync to null
            // to trigger a full offline sync.
            // TODO: Consider not doing this for production
            if (!profile.UserCtx.hv_last_sync_time.HasValue)
            {
                WlkMiTracer.Instance.Log("HVSync.cs:OfflineSyncUser", WlkMiEvent.AppSync,
                    WlkMiCat.Info, string.Format("Deleting information for user {0}",
                    profile.UserCtx.user_id));

                WalkLogModel.ClearUserCache(profile);
            }

            // Processtotals for this user
            WalkLogModel.ProcessTotals(profile.UserCtx.user_id);

            WlkMiTracer.Instance.Log("HVSync.cs:OfflineSyncUser", WlkMiEvent.AppSync,
                WlkMiCat.Info, string.Format("Completed Offline Sync of User: {0}",
                profile.UserCtx.user_id.ToString()));
        }
Exemple #40
0
        void SetModel(ProfileModel profile)
        {
            model = profile;

            viewModel.DioceseList  = structureController.Structure?.Dioceses?.Values.ToList();
            viewModel.FunctionList = structureController.Structure?.Functions?.Values.ToList();

            if (profile == null)
            {
                return;
            }

            viewModel.Firstname          = profile.Firstname;
            viewModel.Lastname           = profile.Lastname;
            viewModel.Residence          = profile.Residence;
            viewModel.Phone              = profile.Phone;
            viewModel.Mail               = profile.Mail;
            viewModel.WoodbadgeCount     = profile.WoodbadgeCount;
            viewModel.FavouriteStage     = profile.FavouriteStage;
            viewModel.RelationshipStatus = profile.RelationshipStatus;
            viewModel.Association        = profile.Association;
            viewModel.IsPriest           = profile.IsPriest;

            if (profile.GeorgesPoints < 0)
            {
                viewModel.GeorgesPoints = "";
            }
            else
            {
                viewModel.GeorgesPoints = profile.GeorgesPoints.ToString();
            }


            if (!String.IsNullOrEmpty(profile.DioceseId))
            {
                Diocese diocese = structureController.Structure.Dioceses[profile.DioceseId];
                viewModel.SelectedDiocese = diocese;
                if (diocese.HasRegions)
                {
                    if (!String.IsNullOrEmpty(profile.RegionId))
                    {
                        Region region = diocese?.Regions[profile.RegionId];
                        viewModel.SelectedRegion = region;
                        if (!String.IsNullOrEmpty(profile.TribeId))
                        {
                            Tribe tribe = region?.Tribes[profile.TribeId];
                            viewModel.SelectedTribe = tribe;
                        }
                    }
                }
                else
                {
                    viewModel.SelectedRegion = null;
                    if (!String.IsNullOrEmpty(profile.TribeId))
                    {
                        Tribe tribe = diocese?.Tribes[profile.TribeId];
                        viewModel.SelectedTribe = tribe;
                    }
                }
            }

            if (!String.IsNullOrEmpty(profile.FunctionId))
            {
                viewModel.SelectedFunction = structureController.Structure.Functions[profile.FunctionId];
            }

            if (String.IsNullOrEmpty(profile.ImageId))
            {
                viewModel.Image = ImageSource.FromFile("avatar.jpg");
            }
            else
            {
                imageApi.Get(profile.ImageId).Subscribe(image => {
                    viewModel.Image = ImageSource.FromStream(() => new MemoryStream(image.Bytes));
                }, cts.Token);
            }
        }
        public ActionResult ProfileDetail(string userName)
        {
            ViewBag.VideoHeight = (Request.Browser.IsMobileDevice) ? 100 : 277;
            ViewBag.VideoWidth = (Request.Browser.IsMobileDevice) ? 225 : 400;

            _ua = new UserAccount(userName);

            var uad = new UserAccountDetail();
            uad.GetUserAccountDeailForUser(_ua.UserAccountID);

            uad.BandsSeen = ContentLinker.InsertBandLinks(uad.BandsSeen, false);
            uad.BandsToSee = ContentLinker.InsertBandLinks(uad.BandsToSee, false);

            var model = new ProfileModel();

            model.ProfilePhotoMainRaw = uad.RawProfilePicUrl;

            if (_ua.UserAccountID > 0)
            {
                model.UserAccountID = _ua.UserAccountID;
                model.PhotoCount = PhotoItems.GetPhotoItemCountForUser(_ua.UserAccountID);
                model.CreateDate = _ua.CreateDate;
            }

            if (_mu != null)
            {
                ViewBag.IsBlocked = BlockedUser.IsBlockedUser(_ua.UserAccountID, Convert.ToInt32(_mu.ProviderUserKey));
                ViewBag.IsBlocking = BlockedUser.IsBlockedUser(Convert.ToInt32(_mu.ProviderUserKey), _ua.UserAccountID);

                if (_ua.UserAccountID == Convert.ToInt32(_mu.ProviderUserKey))
                {
                    model.IsViewingSelf = true;
                }
                else
                {
                    var ucon = new UserConnection();

                    ucon.GetUserToUserConnection(Convert.ToInt32(_mu.ProviderUserKey), _ua.UserAccountID);

                    model.UserConnectionID = ucon.UserConnectionID;

                    if (BlockedUser.IsBlockedUser(Convert.ToInt32(_mu.ProviderUserKey), _ua.UserAccountID))
                    {
                        return RedirectToAction("index", "home");
                    }
                }
            }
            else
            {
                if (uad.MembersOnlyProfile)
                {
                    return RedirectToAction("LogOn", "Account");
                }
            }

            ViewBag.ThumbIcon = uad.FullProfilePicURL;

            SetModelForUserAccount(model, uad);

            //
            var su = new StatusUpdate();
            su.GetMostRecentUserStatus(_ua.UserAccountID);

            if (su.StatusUpdateID > 0)
            {
                model.LastStatusUpdate = su.CreateDate;
                model.MostRecentStatusUpdate = su.Message;
            }

            model.ProfileVisitorCount = ProfileLog.GetUniqueProfileVisitorCount(_ua.UserAccountID);

            GetUserPhotos(model);

            GetUserNews(model);

            model.MetaDescription = _ua.UserName + " " + Messages.Profile + " " +
                                    FromDate.DateToYYYY_MM_DD(_ua.LastActivityDate);

            GetUserPlaylist();

            ForumThreads(_ua.UserAccountID, model);

            if (uad.UserAccountID > 0)
            {
                model.Birthday = uad.BirthDate;

                if (uad.ShowOnMapLegal)
                {
                    // because of the foreign cultures, numbers need to stay in the English version unless a javascript encoding could be added
                    string currentLang = Utilities.GetCurrentLanguageCode();

                    Thread.CurrentThread.CurrentUICulture =
                        CultureInfo.CreateSpecificCulture(SiteEnums.SiteLanguages.EN.ToString());
                    Thread.CurrentThread.CurrentCulture =
                        CultureInfo.CreateSpecificCulture(SiteEnums.SiteLanguages.EN.ToString());

                    model.DisplayOnMap = uad.ShowOnMapLegal;

                    var rnd = new Random();
                    int offset = rnd.Next(10, 100);

                    SiteStructs.LatLong latlong = GeoData.GetLatLongForCountryPostal(uad.Country, uad.PostalCode);

                    if (latlong.latitude != 0 && latlong.longitude != 0)
                    {
                        model.Latitude =
                            Convert.ToDecimal(latlong.latitude + Convert.ToDouble("0.00" + offset))
                                .ToString(CultureInfo.InvariantCulture);
                        model.Longitude =
                            Convert.ToDecimal(latlong.longitude + Convert.ToDouble("0.00" + offset))
                                .ToString(CultureInfo.InvariantCulture);
                    }
                    else
                    {
                        model.DisplayOnMap = false;
                    }

                    Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(currentLang);
                    Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(currentLang);
                }

                ViewBag.ThumbIcon = uad.FullProfilePicThumbURL;

                LoadCurrentImagesViewBag(uad.UserAccountID);
            }

            ViewBag.UserAccountDetail = uad;
            ViewBag.UserAccount = _ua;

            GetUserContacts(model);

            UserAccountDetail uadLooker = null;

            if (_mu != null)
            {
                uadLooker = new UserAccountDetail();
                uadLooker.GetUserAccountDeailForUser(Convert.ToInt32(_mu.ProviderUserKey));
            }

            if (uadLooker != null &&
                (_mu != null && _ua.UserAccountID > 0 && uadLooker.EnableProfileLogging && uad.EnableProfileLogging))
            {
                var pl = new ProfileLog
                {
                    LookedAtUserAccountID = _ua.UserAccountID,
                    LookingUserAccountID = Convert.ToInt32(_mu.ProviderUserKey)
                };

                if (pl.LookingUserAccountID != pl.LookedAtUserAccountID) pl.Create();

                ArrayList al = ProfileLog.GetRecentProfileViews(_ua.UserAccountID);

                if (al != null && al.Count > 0)
                {
                    var uas = new UserAccounts();

                    foreach (UserAccount viewwer in al.Cast<int>().Select(id =>
                        new UserAccount(id))
                        .Where(viewwer => !viewwer.IsLockedOut && viewwer.IsApproved)
                        .TakeWhile(viewwer => uas.Count < Maxcountusers))
                    {
                        uas.Add(viewwer);
                    }
                }
            }

            GetUserAccountVideos();

            // this is either a youtube user or this is a band
            var art = new Artist();
            art.GetArtistByAltname(userName);

            if (art.ArtistID > 0)
            {
                // try this way for dashers
                model.UserName = art.Name;
            }

            var vids = new Videos();
            var sngrs = new SongRecords();

            if (art.ArtistID == 0)
            {
                vids.GetAllVideosByUser(userName);

                var uavs = new UserAccountVideos();
                uavs.GetRecentUserAccountVideos(_ua.UserAccountID, 'U');

                foreach (Video f2 in uavs.Select(uav1 => new Video(uav1.VideoID)).Where(f2 => !vids.Contains(f2)))
                {
                    vids.Add(f2);
                }

                vids.Sort((x, y) => (y.PublishDate.CompareTo(x.PublishDate)));

                model.UserName = _ua != null ? _ua.UserName : userName;
            }
            else
            {
                GetArtistProfile(art, vids);
            }

            vids.Sort((p1, p2) => p2.PublishDate.CompareTo(p1.PublishDate));
            sngrs.AddRange(vids.Select(v1 => new SongRecord(v1)));

            if (_mu != null && _ua.UserAccountID != Convert.ToInt32(_mu.ProviderUserKey))
            {
                var uc1 = new UserConnection();

                uc1.GetUserToUserConnection(_ua.UserAccountID, Convert.ToInt32(_mu.ProviderUserKey));

                if (uc1.UserConnectionID > 0)
                {
                    switch (uc1.StatusType)
                    {
                        case 'C':
                            if (uc1.IsConfirmed)
                            {
                                model.IsCyberFriend = true;
                            }
                            else
                            {
                                model.IsWatingToBeCyberFriend = true;
                            }
                            break;
                        case 'R':
                            if (uc1.IsConfirmed)
                            {
                                model.IsRealFriend = true;
                            }
                            else
                            {
                                model.IsWatingToBeRealFriend = true;
                            }
                            break;
                        default:
                            model.IsDeniedCyberFriend = true;
                            model.IsDeniedRealFriend = true;
                            break;
                    }
                }
            }

            if (sngrs.Count == 0 && art.ArtistID == 0 && _ua.UserAccountID == 0)
            {
                // no longer exists
                Response.RedirectPermanent("/");
                return new EmptyResult();
            }

            var sngDisplay = new SongRecords();
            sngDisplay.AddRange(from sr1 in sngrs
                let vidToShow = new Video(sr1.VideoID)
                where vidToShow.IsEnabled
                select sr1);

            model.SongRecords = sngDisplay.VideosList();

            return View(model);
        }
 public JsonResult ExcluirProfile(int id)
 {
     return(Json(ProfileModel.ExcludeId(id)));
 }
        /// <summary>
        /// The get profile for user.
        /// </summary>
        /// <param name="memberId">The member id for the profile.</param>
        /// <param name="loginCredential">The login credential.</param>
        /// <returns>The System.Threading.Tasks.Task`1[TResult -&gt; Gep13.WindowsPhone.VBForumsMetro.Models.ProfileModel].</returns>
        public async Task<ProfileModel> GetProfileForUser(int memberId, LoginCredentialModel loginCredential)
        {
            var uri = new Uri("http://www.vbforums.com/login.php?do=login");

            var postString =
                string.Format(
                    "do=login&url=%2Fusercp.php&vb_login_md5password=&vb_login_md5password_utf=&s=&securitytoken=guest&vb_login_username={0}&vb_login_password={1}",
                    loginCredential.UserName,
                    loginCredential.Password);

            var cookieContainer = new CookieContainer();
            var request = WebRequest.CreateHttp(uri);
            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            request.CookieContainer = cookieContainer;

            var requestSteam = await request.GetRequestStreamAsync();

            using (var writer = new StreamWriter(requestSteam))
            {
                writer.Write(postString);
            }

            var loginResponse = await request.GetResponseAsync();
            loginResponse.Close();

            uri = new Uri(string.Format("http://www.vbforums.com/member.php?u={0}", memberId));

            request = WebRequest.CreateHttp(uri);
            request.Method = "GET";
            request.CookieContainer = cookieContainer;

            var response = (HttpWebResponse)await request.GetResponseAsync();
            var statusCode = response.StatusCode;

            if ((int)statusCode >= 400)
            {
                return null;
            }     

            string responseString;
            using (var responseStream = new StreamReader(response.GetResponseStream()))
            {
                responseString = await responseStream.ReadToEndAsync();
            }

            var profile = new ProfileModel();

            // Example HTML that is being parsed at this point
            // <li><span class="shade">Join Date:</span> Nov 16th, 2004</li>
            var rx = new Regex("<li><span class=\"shade\">Join Date:</span> (.* [0-9]{1,2}).*, ([0-9]{2,4})</li>", RegexOptions.Compiled | RegexOptions.IgnoreCase);
            var matches = rx.Matches(responseString);
            
            var joinDate = DateTime.MinValue;

            if (matches.Count != 1)
            {
                joinDate = DateTime.MaxValue;
            }
            else
            {
                var dateTimeString = string.Format(
                    "{0}, {1}", matches[0].Groups[1], matches[0].Groups[2]);

                if (!DateTime.TryParseExact(dateTimeString, "MMM d, yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out joinDate))
                {
                    joinDate = DateTime.MaxValue;
                }
            }

            profile.JoinDate = joinDate;

            // Example HTML that is being parsed at this point
            // <li><span class="shade">Posts Per Day:</span> 7.61</li>
            rx = new Regex("<li><span class=\"shade\">Posts Per Day:</span> (.*)</li>", RegexOptions.Compiled | RegexOptions.IgnoreCase);
            matches = rx.Matches(responseString);
            var postsPerDay = 0d;

            if (matches.Count != 1)
            {
                postsPerDay = -1d;
            }
            else
            {
                if (!double.TryParse(matches[0].Groups[1].ToString(), out postsPerDay))
                {
                    postsPerDay = -1d;
                }
            }

            profile.PostsPerDay = postsPerDay;

            // Example HTML that is being parsed at this point
            // <li><span class="shade">Total Posts:</span> 21,358</li>
            rx = new Regex("<li><span class=\"shade\">Total Posts:</span> (.*)</li>", RegexOptions.Compiled | RegexOptions.IgnoreCase);
            matches = rx.Matches(responseString);
            var posts = 0;

            if (matches.Count != 1)
            {
                posts = -1;
            }
            else
            {
                if (!int.TryParse(matches[0].Groups[1].ToString(), out posts))
                {
                    posts = -1;
                }
            }

            profile.Posts = posts;

            // Example HTML that is being parsed at this point
            // <td id="profilepic_cell" class="tborder alt2"><img src="image.php?u=53106&amp;dateline=1277553514&amp;type=profile"  width="64" height="64"  alt="gep13's Profile Picture" /></td>
            rx = new Regex("<td id=\"profilepic_cell\" class=\"tborder alt2\"><img src=\"(.*)\"", RegexOptions.Compiled | RegexOptions.IgnoreCase);
            matches = rx.Matches(responseString);

            profile.ProfilePictureUrl = matches.Count != 1 ? null : new Uri(matches[0].ToString());

            // Example HTML that is being parsed at this point
            // <strong>Welcome, <a href="member.php?u=53106">gep13</a>.</strong><br />
            var pattern = string.Format("<strong>Welcome, <a href=\"member.php{0}u=.*\">(.*)</a>", Regex.Escape("?"));

            rx = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
            matches = rx.Matches(responseString);

            profile.UserName = matches.Count != 1 ? string.Empty : matches[0].Groups[1].ToString();

            return profile;
        }
Exemple #44
0
        public static string GetProfileUrlWithDomain(this UrlHelper helper, ProfileModel member)
        {
            var rootUrl = helper.RequestContext.HttpContext.Request.Url.GetLeftPart(UriPartial.Authority);

            return(rootUrl + "/members/" + (member.HasGitHubUsername ? member.GitHubUsername : "******" + member.Id) + "/");
        }
        public ActionResult Profile(ProfileModel model)
        {
            var member = new Member{
                Email = model.Email,
                UserName = model.UserName,
                OpenId = MemberInformations.OpenId};
            _membershipService.EditMemberProfile(member);

            return RedirectToAction("Profile");
        }
        private static void NativeStudentPropertiesShouldBeMapped(Web.Data.Entities.Student student, ProfileModel profileModel)
        {
            profileModel.StudentUsi.ShouldBe(student.StudentUSI);
            profileModel.StudentName.FirstName.ShouldBe(student.FirstName);
            profileModel.StudentName.LastName.ShouldBe(student.LastSurname);
            profileModel.BiographicalInfo.BirthDate.ShouldBe(student.BirthDate.ToShortDateString());

            var studentRace = student.StudentRaces.First();

            profileModel.BiographicalInfo.Race.ShouldBe((RaceTypeEnum)studentRace.RaceTypeId);
            profileModel.BiographicalInfo.RaceForDisplay.ShouldBe(((RaceTypeEnum)studentRace.RaceTypeId).Humanize());
            profileModel.BiographicalInfo.HispanicLatinoEthnicity.ShouldBe(student.HispanicLatinoEthnicity);
            profileModel.BiographicalInfo.Sex.ShouldBe((SexTypeEnum)student.SexTypeId);

            var studentProfileHomeLanguage = profileModel.BiographicalInfo.HomeLanguage;

            studentProfileHomeLanguage.ShouldBe((LanguageDescriptorEnum)student.StudentLanguages.First().LanguageDescriptorId);
        }
Exemple #47
0
        public void UpdateProfileByStarsId(ProfileModel model)
        {
            ProfileRepository _profile = new ProfileRepository();

            _profile.UpdateProfileByStarsId(model);
        }
        private void GetUserContacts(ProfileModel model)
        {
            var ucons = new UserConnections();
            ucons.GetUserConnections(_ua.UserAccountID);
            ucons.Shuffle();

            var irlContacts = new UserAccounts();
            var cyberAssociates = new UserAccounts();

            foreach (UserConnection uc1 in ucons.Where(uc1 => uc1.IsConfirmed))
            {
                UserAccount userCon;
                switch (uc1.StatusType)
                {
                    case 'C':
                        if (cyberAssociates.Count >= Maxcountusers) continue;

                        userCon = uc1.ToUserAccountID != _ua.UserAccountID
                            ? new UserAccount(uc1.ToUserAccountID)
                            : new UserAccount(uc1.FromUserAccountID);
                        cyberAssociates.Add(userCon);
                        break;
                    case 'R':
                        if (irlContacts.Count >= Maxcountusers) continue;

                        userCon = uc1.ToUserAccountID != _ua.UserAccountID
                            ? new UserAccount(uc1.ToUserAccountID)
                            : new UserAccount(uc1.FromUserAccountID);
                        irlContacts.Add(userCon);
                        break;
                }
            }

            if (irlContacts.Count > 0)
            {
                model.IRLFriendCount = irlContacts.Count;
            }

            if (cyberAssociates.Count > 0)
            {
                model.CyberFriendCount = cyberAssociates.Count;
            }
        }
 public async Task UpdateProfileAsync(ProfileModel profile)
 {
     await _ProfileRepository.UpdateProfileAsync(profile);
 }
        private void GetUserPhotos(ProfileModel model)
        {
            var ptiems = new PhotoItems();
            ptiems.GetUserPhotos(_ua.UserAccountID);

            if (ptiems.Count > 0)
            {
                ptiems.Sort((x, y) => (y.CreateDate.CompareTo(x.CreateDate)));

                var ptiemsDisplay = new PhotoItems();

                const int maxPhotos = 8;

                foreach (PhotoItem pitm1 in ptiems)
                {
                    pitm1.UseThumb = true;
                    if (ptiemsDisplay.Count < maxPhotos)
                    {
                        ptiemsDisplay.Add(pitm1);
                    }
                    else break;
                }

                ptiemsDisplay.UseThumb = true;
                ptiemsDisplay.ShowTitle = false;

                model.HasMoreThanMaxPhotos = (ptiems.Count > maxPhotos);
                ptiemsDisplay.IsUserPhoto = true;
                model.PhotoItems = ptiemsDisplay.ToUnorderdList;
            }
        }
Exemple #51
0
        public static void OnlineSyncUser(ProfileModel profile, PersonInfo info, bool partialSync)
        {
            string syncType = "partial";
            DateTime? lastSyncTime = profile.UserCtx.hv_last_sync_time;
            DateTime timeStamp = DateTime.Now;

            // reset lastsynctime if this is a full sync
            if (!lastSyncTime.HasValue || !partialSync)
            {
                WlkMiTracer.Instance.Log("HVSync.cs:OnlineSyncUser", WlkMiEvent.UserSync,
                      WlkMiCat.Info, string.Format("Full syncing for User: {0}",
                        profile.UserCtx.user_id));
                lastSyncTime = null;
            }

            // Retrieve the latest info from HealthVault
            HealthRecordItemCollection items =
                GetHVItemsOnline(info, lastSyncTime);
            if (items != null && items.Count > 0)
            {
                foreach (HealthRecordItem item in items)
                {
                    // Do the distinct per item work
                    ProcessStepsHealthItem(item, profile);
                }
            }

            //only update the last sync time if we are able to download items
            if (items != null)
            {
                //set last sync time
                profile.UserCtx.hv_last_sync_time = timeStamp;
                profile.Save();
            }

            // Clear the WlkMi data cache if the last sync is null or this is a full sync
            if (!lastSyncTime.HasValue || !partialSync)
            {
                WlkMiTracer.Instance.Log("HVSync.cs:OnlineSyncUser", WlkMiEvent.UserSync,
                      WlkMiCat.Info, string.Format("Full sync deleting information for User: {0}",
                        profile.UserCtx.user_id));
                lastSyncTime = null;
                WalkLogModel.ClearUserCache(profile);
                syncType = "full";
            }

            //Processtotals for this user
            WalkLogModel.ProcessTotals(profile.UserCtx.user_id);

            WlkMiTracer.Instance.Log("HVSync:OnlineSyncUser", WlkMiEvent.UserSync,
                WlkMiCat.Info, string.Format("Completed Online {1} Sync of User: {0}",
                profile.UserCtx.user_id.ToString(), syncType));
        }
        private void SetModelForUserAccount(ProfileModel model, UserAccountDetail uad)
        {
            //
            model.UserName = _ua.UserName;
            model.CreateDate = _ua.CreateDate;
            model.LastActivityDate = _ua.LastActivityDate;
            //
            model.DisplayAge = uad.DisplayAge;
            model.Age = uad.YearsOld;
            model.BandsSeen = uad.BandsSeen;
            model.BandsToSee = uad.BandsToSee;
            model.HardwareAndSoftwareSkills = uad.HardwareSoftware;
            model.MessageToTheWorld = uad.AboutDescription;

            model.YouAreFull = uad.Sex;
            model.InterestedInFull = uad.InterestedFull;
            model.RelationshipStatusFull = uad.RelationshipStatusFull;
            model.RelationshipStatus = uad.RelationshipStatus;
            model.InterestedIn = uad.InterestedIn;
            model.YouAre = uad.YouAre;

            model.Website = uad.ExternalURL;
            model.CountryCode = uad.Country;
            model.CountryName = uad.CountryName;
            model.IsBirthday = uad.IsBirthdayToday;
            model.ProfilePhotoMain = uad.FullProfilePicURL;

            model.ProfilePhotoMainThumb = uad.FullProfilePicThumbURL;
            model.DefaultLanguage = uad.DefaultLanguage;

            model.EnableProfileLogging = uad.EnableProfileLogging;
            model.Handed = uad.HandedFull;
            model.RoleIcon = uad.SiteBages;
        }
        public ActionResult Profile()
        {
            var currentlyLoggedInUserId = (int)Session["UserId"];
            var user = UserRepository.GetUser(currentlyLoggedInUserId);

            var profileModel = new ProfileModel();

            profileModel.UserId = user.Id;
            profileModel.Username = user.Username;
            profileModel.Gender = user.Gender;
            profileModel.About = user.About;
            profileModel.Image = user.Image;
            profileModel.age = CountClass.CalculateAge(user.Birthdate);
            profileModel.FirstName = user.FirstName;
            profileModel.LastName = user.LastName;
            profileModel.City = user.City;
            profileModel.Quote = user.Quote;
            profileModel.Status = user.Status;
            if (user.Length != null) profileModel.Length = (decimal)user.Length;
            if (user.Weight != null) profileModel.Weight = (decimal)user.Weight;

            var dalWallModel = WallRepository.getWallMessages(currentlyLoggedInUserId);
            var ListOfwallModel = new List<WallModel>();
            foreach(var item in dalWallModel)
            {
                var wall = new WallModel();
                wall.date = item.date;
                wall.Message=item.message;
                wall.PosterID= item.posterID;
                wall.posterImage = item.posterImage;
                wall.Username = item.posterUsename;
                wall.MessageID = item.MessageID;
                ListOfwallModel.Add(wall);
            }
            profileModel.ProfileWallList = ListOfwallModel;

            return View(profileModel);
        }
Exemple #54
0
        public bool UpdateProfileWslxIdByStarsId(ProfileModel model)
        {
            ProfileRepository _profile = new ProfileRepository();

            return(_profile.UpdateProfileWslxIdByStarsId(model));
        }
Exemple #55
0
        public ProfileModel UserProfile(int userid)
        {
            var profile = new ProfileModel();
            try
            {
                var currentUser = UserManager.Current();

                var user = _repository.GetById(userid);
                if (user != null)
                {
                    if (currentUser != null)
                    profile.JobStatus=  _repository.GetjobStatusByUserId(user.Row_Id, currentUser.OrgId.Value);
                    profile.User = user;

                }

            }
            catch (Exception ex)
            {

                string msg = ex.Message;
            }

            return profile;
        }