Exemplo n.º 1
0
        public ActionResult EditDetail(ProfileDetail details, int section)
        {
            var me = GetMyProfileId();

            _profileRepo.EditDetails(details, (OkbConstants.ProfileDetailSections)section, me);

            return Redirect("/profile");
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
 public ProfileDetail GetProfileDetail(int profileId)
 {
     var db = new OkbDbContext();
     var detail = db.ProfileDetails.Find(profileId);
     if (detail==null)
     {
         detail = new ProfileDetail();
     }
     return detail;
 }