public static void CreatePhysicalProfiles(DTO.PhysicalProfileDTO physicalProfileDTO)
        {
            var db = new MealPlannerDbEntities();
            var physicalProfile = convertToEntity(physicalProfileDTO);

            db.PhysicalProfiles.Add(physicalProfile);
            db.SaveChanges();
        }
        private static PhysicalProfile convertToEntity(DTO.PhysicalProfileDTO physicalProfileDTO)
        {
            var physicalProfile = new PhysicalProfile();

            physicalProfile.UserName          = physicalProfileDTO.UserName;
            physicalProfile.DoOption          = physicalProfileDTO.DoOption;
            physicalProfile.Gender            = physicalProfileDTO.Gender;
            physicalProfile.Height            = physicalProfileDTO.Height;
            physicalProfile.Weight            = physicalProfileDTO.Weight;
            physicalProfile.Age               = physicalProfileDTO.Age;
            physicalProfile.ActivityLevel     = physicalProfileDTO.ActivityLevel;
            physicalProfile.FinalWeight       = physicalProfileDTO.FinalWeight;
            physicalProfile.DaysToGo          = physicalProfileDTO.DaysToGo;
            physicalProfile.BMI               = physicalProfileDTO.BMI;
            physicalProfile.SuggestedCalories = physicalProfileDTO.SuggestedCalories;


            return(physicalProfile);
        }
Exemplo n.º 3
0
        // get user input from server controls
        private DTO.PhysicalProfileDTO buildPhysicalProfile()
        {
            DTO.PhysicalProfileDTO physicalProfileDTO = new DTO.PhysicalProfileDTO();


            physicalProfileDTO.UserName      = Session["userName"].ToString();
            physicalProfileDTO.DoOption      = determineDoOption();
            physicalProfileDTO.Gender        = determineGender();
            physicalProfileDTO.Height        = physical.ConvertHeight((Convert.ToInt32(txbheightfeet.Text)), Convert.ToInt32(txbheightinch.Text)); //store the height in database in cm, need to convert to cm before storing into database
            physicalProfileDTO.Weight        = physical.ConvertWeight(Convert.ToInt32(txbWeight.Text));                                            //store the weight in database in kg, need to convert to kg before storing into database
            physicalProfileDTO.Age           = Convert.ToInt32(txbAge.Text);
            physicalProfileDTO.ActivityLevel = determineActivityLevel();
            physicalProfileDTO.FinalWeight   = Convert.ToInt32(tbxGoalWeight.Text);
            physicalProfileDTO.DaysToGo      = Convert.ToInt32(tbxDaysToGo.Text);

            physicalProfileDTO.BMI = physical.BMIcalculation(physicalProfileDTO.Weight, physicalProfileDTO.Height);
            LabelMBI.Text          = physicalProfileDTO.BMI.ToString();

            physicalProfileDTO.SuggestedCalories = physical.GetCalories(physicalProfileDTO.Height, physicalProfileDTO.Weight, physicalProfileDTO.Age, physicalProfileDTO.Gender, physicalProfileDTO.ActivityLevel);
            LabelSuggestCalories.Text            = physicalProfileDTO.SuggestedCalories.ToString();

            return(physicalProfileDTO);
        }
Exemplo n.º 4
0
 public static void CreatePhysicalProfiles(DTO.PhysicalProfileDTO physicalProfileDTO)
 {
     Persistence.PhysicalProfileRepository.CreatePhysicalProfiles(physicalProfileDTO);
 }