示例#1
0
 /// <summary>
 /// Updates the activity's last added date in the Session
 /// </summary>
 protected void UpdateActivityLastAdded(OkbConstants.ActivityCategories category)
 {
     if (category == OkbConstants.ActivityCategories.Joined) return; //no need to store join activity
     Session["Activity:" + category.ToString()] = DateTime.Now;
 }
        public void EditDetails(ProfileDetail details, OkbConstants.ProfileDetailSections section, int profileId)
        {
            var db = new OkbDbContext();

            //check if we're updating or adding
            var currDetails = db.ProfileDetails.Find(profileId);
            if (currDetails==null)
            {
                //adding new Profile Detail row
                details.ProfileId = profileId;
                db.ProfileDetails.Add(details);
                db.SaveChanges();
                return;
            }

            //otherwise we're updating
            //db.ProfileDetails.Attach(details);
            //db.Entry(details).State = System.Data.Entity.EntityState.Modified;

            switch (section)
            {
                case OkbConstants.ProfileDetailSections.Basic:
                    currDetails.LookingFor = details.LookingFor;
                    currDetails.Height = details.Height;
                    currDetails.Education = details.Education;
                    currDetails.RelationshipStatus = details.RelationshipStatus;
                    currDetails.HaveChildren = details.HaveChildren;
                    currDetails.WantChildren = details.WantChildren;
                    currDetails.Nationality = details.Nationality;
                    currDetails.MonthlyIncome = details.MonthlyIncome;
                    currDetails.LivingSituation = details.LivingSituation;
                    currDetails.CarSituation = details.CarSituation;
                    currDetails.EconomicConcept = details.EconomicConcept;
                    //db.Entry(details).Property(col => col.LookingFor).IsModified = true;
                    //db.Entry(details).Property(col => col.Height).IsModified = true;
                    //db.Entry(details).Property(col => col.Education).IsModified = true;
                    //db.Entry(details).Property(col => col.RelationshipStatus).IsModified = true;
                    //db.Entry(details).Property(col => col.HaveChildren).IsModified = true;
                    //db.Entry(details).Property(col => col.WantChildren).IsModified = true;
                    //db.Entry(details).Property(col => col.Nationality).IsModified = true;
                    //db.Entry(details).Property(col => col.MonthlyIncome).IsModified = true;
                    //db.Entry(details).Property(col => col.LivingSituation).IsModified = true;
                    //db.Entry(details).Property(col => col.CarSituation).IsModified = true;
                    //db.Entry(details).Property(col => col.EconomicConcept).IsModified = true;
                    break;

                case OkbConstants.ProfileDetailSections.Lifestyle:
                    currDetails.Smoke = details.Smoke;
                    currDetails.Drink = details.Drink;
                    currDetails.Exercise = details.Exercise;
                    currDetails.Eating = details.Eating;
                    currDetails.Shopping = details.Shopping;
                    currDetails.Religion = details.Religion;
                    currDetails.SleepSchedule = details.SleepSchedule;
                    currDetails.SocialCircle = details.SocialCircle;
                    currDetails.MostMoney = details.MostMoney;
                    currDetails.Housework = details.Housework;
                    currDetails.LovePets = details.LovePets;
                    currDetails.HavePets = details.HavePets;
                    break;

                case OkbConstants.ProfileDetailSections.Job:
                    currDetails.Job = details.Job;
                    currDetails.Industry = details.Industry;
                    currDetails.WorkHours = details.WorkHours;
                    currDetails.CareerAndFamily = details.CareerAndFamily;
                    break;

                case OkbConstants.ProfileDetailSections.Appearance:
                    currDetails.BodyType = details.BodyType;
                    currDetails.FaceType = details.FaceType;
                    currDetails.EyeColor = details.EyeColor;
                    currDetails.EyeShape = details.EyeShape;
                    currDetails.HairColor = details.HairColor;
                    currDetails.HairLength = details.HairLength;
                    currDetails.HairType = details.HairType;
                    currDetails.SkinType = details.SkinType;
                    currDetails.Muscle = details.Muscle;
                    currDetails.HealthCondition = details.HealthCondition;
                    currDetails.DressStyle = details.DressStyle;
                    break;

                case OkbConstants.ProfileDetailSections.Personality:
                    currDetails.Sociability = details.Sociability;
                    currDetails.Humour = details.Humour;
                    currDetails.Temper = details.Temper;
                    currDetails.Feelings = details.Feelings;
                    break;

                default:
                    //invalid section. fail silently?
                    break;
            }

            db.SaveChanges();
        }
示例#3
0
        /// <summary>
        /// Returns true if it is ok to add the activity to the feed. It is OK if the time
        /// elapsed is less than the pre-defined interval since the last time the activity was added.
        /// We use Session to store the last added activity time. Prevents the activity feed from
        /// being overloaded with a user's activities.
        /// </summary>
        protected bool IsOkToAddActivity(OkbConstants.ActivityCategories category)
        {
            DateTime threshold;

            switch (category)
            {
                case OkbConstants.ActivityCategories.Joined:
                    return true;
                case OkbConstants.ActivityCategories.UploadedPhoto:
                    threshold = DateTime.Now.AddMinutes(-OkbConstants.ACTIVITY_UPLOADEDPHOTO_INTERVAL);
                    break;
                case OkbConstants.ActivityCategories.EditedProfileText:
                    threshold = DateTime.Now.AddMinutes(-OkbConstants.ACTIVITY_EDITEDPROFILE_INTERVAL);
                    break;
                case OkbConstants.ActivityCategories.AnsweredQuestion:
                    threshold = DateTime.Now.AddMinutes(-OkbConstants.ACTIVITY_ANSWEREDQUESTION_INTERVAL);
                    break;
                default:
                    //throw exception?
                    return true;
            }

            var lastAdded = Session["Activity:" + category.ToString()];

            if (lastAdded == null || (DateTime)lastAdded < threshold)
            {
                return true;
            }

            return false;
        }