public SpirometryClassification(SpirometryClassificationParameters parameters) { _spirometry = parameters.Spirometry ?? throw new ArgumentNullException(nameof(parameters.Spirometry)); _patient = parameters.Patient ?? throw new ArgumentNullException(nameof(parameters.Patient)); _bodyComposition = parameters.BodyComposition ?? throw new ArgumentNullException(nameof(parameters.BodyComposition)); }
public string InsertChallenger(Challenger challenger, BodyComposition compo, byte oppNo) { try { using (VShapeUpDataContext _ctx = new VShapeUpDataContext()) { string runNo = RunningNo(PREFIX, "", ""); string docNo = PREFIX + runNo; UpdateIndexMasTer(Convert.ToInt32(runNo), PREFIX, "", ""); challenger.UserNo = docNo; challenger.LastName = ""; challenger.NickName = ""; challenger.IsChanllenge = false; challenger.CreatedAt = DateTime.Now; //compo.MeasureDate = DateTime.Now.Date; challenger.OOP = oppNo; challenger.BodyCompositions.Add(compo); _ctx.Challengers.InsertOnSubmit(challenger); _ctx.SubmitChanges(); return(docNo); } } catch { return("FAILED"); } }
public IHttpActionResult PutBodyComposition(int id, BodyComposition bodyComposition) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != bodyComposition.ID) { return(BadRequest()); } db.Entry(bodyComposition).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!BodyCompositionExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public string AddCompo(string userNo, BodyComposition compo) { try { using (VShapeUpDataContext _ctx = new VShapeUpDataContext()) { var challenger = (from x in _ctx.Challengers where x.UserNo == userNo select x).FirstOrDefault(); //challenger.BodyCompositions.Clear(); //compo.MeasureDate = DateTime.Now.Date; challenger.BodyCompositions.Add(compo); //_ctx.Challengers.InsertOnSubmit(challenger); _ctx.SubmitChanges(); return("OK"); } } catch (Exception ex) { //return "FAILED"; return(ex.Message); } }
public SpirometryClassificationParameters(Spirometry spirometry, Patient patient, BodyComposition bodyComposition) { Spirometry = spirometry; Patient = patient; BodyComposition = bodyComposition; }
public void WhenHeathVaultBodyCompositionTransformedToFhir_ThenCodeAndValuesEqual() { var bodyComposition = new BodyComposition( new ApproximateDateTime(new LocalDateTime(2017, 8, 3, 8, 30, 01)), new CodableValue("Body fat percentage", new CodedValue("fat-percent", "body-composition-measurement-names", "wc", "1")), new BodyCompositionValue { MassValue = new WeightValue(10), PercentValue = 0.15 } ) { MeasurementMethod = new CodableValue("DXA/DEXA", new CodedValue("DXA", "body-composition-measurement-methods", "wc", "1")), Site = new CodableValue("Trunk", new CodedValue("Trunk", "body-composition-sites", "wc", "1")) }; var observation = bodyComposition.ToFhir(); Assert.IsNotNull(observation); Assert.AreEqual(HealthVaultThingTypeNameCodes.BodyComposition, observation.Code.Coding[0]); Assert.AreEqual("DXA", observation.Method.Coding[0].Code); Assert.AreEqual("Trunk", observation.BodySite.Coding[0].Code); Assert.AreEqual("fat-percent", observation.Component[0].Code.Coding[0].Code); var massValue = observation.Component[1].Value as Quantity; Assert.IsNotNull(massValue); Assert.AreEqual(10, massValue.Value); Assert.AreEqual(UnitAbbreviations.Kilogram, massValue.Unit); var percentageValue = observation.Component[2].Value as Quantity; Assert.IsNotNull(percentageValue); Assert.AreEqual((decimal)0.15, percentageValue.Value); Assert.AreEqual(UnitAbbreviations.Percent, percentageValue.Unit); }
public override UrbComponentData GetComponentData() { UrbComponentData Data = base.GetComponentData(); Data.Fields = new UrbFieldData[] { new UrbFieldData { Name = "Height", Value = Height } }; UrbSubstance[] BodyContents = (BodyComposition == null)? BodyRecipe : BodyComposition.GetCompositionIngredients(); Data.FieldArrays = new UrbFieldArrayData[] { UrbEncoder.GetArrayFromSubstances("BodyRecipe", BodyRecipe), UrbEncoder.GetArrayFromSubstances("BodyContents", BodyContents), UrbEncoder.GetArrayFromSubstances("CriticalBodyPartAmounts", CriticalBodyPartAmounts), }; Data.StringArrays = new UrbStringArrayData[] { UrbEncoder.EnumsToArray("SkinRecipe", SkinRecipe), }; return(Data); }
public ActionResult Edit([Bind(Include = "ID,Owner,Height,Weight,BodyFat,Logged")] BodyComposition bodyComposition) { if (ModelState.IsValid) { db.Entry(bodyComposition).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(bodyComposition)); }
public IHttpActionResult GetBodyComposition(int id) { BodyComposition bodyComposition = db.BodyComps.Find(id); string owner = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value; if (bodyComposition == null || bodyComposition.Owner != owner) { return(NotFound()); } return(Ok(bodyComposition)); }
private BodyCompositionExpanded( BodyComposition bodyComposition, double visceralFat, double percentBodyFat) : base( bodyComposition.Height, bodyComposition.Waist, bodyComposition.Hips, bodyComposition.Weight) { VisceralFat = visceralFat; PercentBodyFat = percentBodyFat; }
public ActionResult DeleteConfirmed(int id) { BodyComposition bodyComposition = db.BodyComps.Find(id); string owner = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value; if (bodyComposition == null || bodyComposition.Owner != owner) { return(HttpNotFound()); } db.BodyComps.Remove(bodyComposition); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "ID,Owner,Height,Weight,BodyFat,Logged")] BodyComposition bodyComposition) { if (ModelState.IsValid) { bodyComposition.Owner = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value; bodyComposition.Logged = DateTime.UtcNow; db.BodyComps.Add(bodyComposition); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(bodyComposition)); }
internal static Observation ToFhirInternal(BodyComposition bodyComposition, Observation observation) { observation.Category = new List <CodeableConcept> { FhirCategories.VitalSigns }; observation.Effective = bodyComposition.When.ToFhir(); observation.Code = HealthVaultVocabularies.GenerateCodeableConcept(HealthVaultThingTypeNameCodes.BodyComposition); if (bodyComposition.MeasurementName != null) { observation.Component.Add(new Observation.ComponentComponent { Code = bodyComposition.MeasurementName.ToFhir() }); } if (bodyComposition.Value.MassValue != null) { var massValue = new Observation.ComponentComponent { Code = bodyComposition.MeasurementName.ToFhir(), Value = new Quantity((decimal)bodyComposition.Value.MassValue.Kilograms, UnitAbbreviations.Kilogram) }; observation.Component.Add(massValue); } if (bodyComposition.Value.PercentValue.HasValue) { var percentageValue = new Observation.ComponentComponent { Code = bodyComposition.MeasurementName.ToFhir(), Value = new Quantity((decimal)bodyComposition.Value.PercentValue.Value, UnitAbbreviations.Percent) }; observation.Component.Add(percentageValue); } if (bodyComposition.Site != null) { observation.BodySite = bodyComposition.Site.ToFhir(); } if (bodyComposition.MeasurementMethod != null) { observation.Method = bodyComposition.MeasurementMethod.ToFhir(); } return(observation); }
public IHttpActionResult PostBodyComposition(BodyComposition bodyComposition) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } string owner = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value; bodyComposition.Owner = owner; bodyComposition.Logged = DateTime.UtcNow; db.BodyComps.Add(bodyComposition); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = bodyComposition.ID }, bodyComposition)); }
// GET: BodyComposition/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BodyComposition bodyComposition = db.BodyComps.Find(id); string owner = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value; if (bodyComposition == null || bodyComposition.Owner == owner) { return(HttpNotFound()); } return(View(bodyComposition)); }
public void WhenHeathVaultBodyCompositionOnlyWeightTransformedToFhir_ThenCodeAndValuesEqual() { var bodyComposition = new BodyComposition( new ApproximateDateTime(new LocalDateTime(2017, 8, 3, 8, 30, 01)), new CodableValue("Body fat percentage", new CodedValue("fat-percent", "body-composition-measurement-names", "wc", "1")), new BodyCompositionValue { MassValue = new WeightValue(10) } ); var observation = bodyComposition.ToFhir(); Assert.IsNotNull(observation); Assert.AreEqual(1, observation.Code.Coding.Count); Assert.AreEqual("fat-percent", observation.Component[0].Code.Coding[0].Code); Assert.AreEqual(2, observation.Component.Count); var massValue = observation.Component[1].Value as Quantity; Assert.IsNotNull(massValue); Assert.AreEqual(10, massValue.Value); Assert.AreEqual(UnitAbbreviations.Kilogram, massValue.Unit); }
public override void OnEnable() { Assert.IsNotNull(BodyComposition); BodyComposition.SetSize(mAgent.Tileprint.TileCount * Height); base.OnEnable(); }
//导入,未完成 public async Task <ActionResult> Import() { try { HttpPostedFileBase file = Request.Files["file"];//接收客户端传递过来的数据. if (file == null) { return(Content("请选择上传的Excel文件")); } else { //对文件的格式判断,此处省略 //PeriodicTestResult db = new PeriodicTestResult();//EF上下文对象 Stream inputStream = file.InputStream; HSSFWorkbook hssfworkbook = new HSSFWorkbook(inputStream); NPOI.SS.UserModel.ISheet sheet = hssfworkbook.GetSheetAt(0); // IRow headerRow = sheet.GetRow(0);//第一行为标题行 // int cellCount = headerRow.LastCellNum;//LastCellNum = PhysicalNumberOfCells int rowCount = sheet.LastRowNum;//LastRowNum = PhysicalNumberOfRows - 1 for (int i = (sheet.FirstRowNum + 1); i <= rowCount; i++) { IRow row = sheet.GetRow(i); BodyComposition model = new BodyComposition(); if (row != null) { if (row.GetCell(0) != null) { var username = GetCellValue(row.GetCell(0)); var user = _sysUserService.GetAll(a => a.UserName == username).FirstOrDefault(); if (user != null) { model.SysUserId = user.Id; if (row.GetCell(1) != null) { model.Testdate = DateTime.Parse(GetCellValue(row.GetCell(1))).ToString("yyyy-MM-dd"); } if (row.GetCell(2) != null) { model.BF = double.Parse(GetCellValue(row.GetCell(2))); } if (row.GetCell(3) != null) { model.Muscle = double.Parse(GetCellValue(row.GetCell(3))); } if (row.GetCell(4) != null) { model.Fat = double.Parse(GetCellValue(row.GetCell(4))); } if (row.GetCell(5) != null) { model.BoneMSalt = double.Parse(GetCellValue(row.GetCell(5))); } model.Weight = model.Muscle + model.Fat + model.BoneMSalt; _bodyCompositionService.Save(null, model); } } } } await _unitOfWork.CommitAsync(); return(RedirectToAction("Index")); } } catch (Exception e) { return(Content(e.ToString())); } }
protected void bAjaxPostback_Click(object sender, EventArgs e) { string status = string.Empty; try { Affine.Data.Managers.IDataManager dataMan = Affine.Data.Managers.LINQ.DataManager.Instance; aqufitEntities entities = new aqufitEntities(); switch (hiddenAjaxAction.Value) { case "connectCompAthlete": long aid = Convert.ToInt64(hiddenAjaxValue.Value); CompetitionAthlete athlete = entities.CompetitionAthletes.Include("CompetitionWODs").Include("CompetitionWODs.WOD").Include("CompetitionWODs.WOD.WODType").Include("CompetitionAffiliate").Include("CompetitionAffiliate.CFAffiliate").Include("CompetitionAffiliate.CFAffiliate.UserSetting").FirstOrDefault(a => a.Id == aid); // first lets get any info we can off the profile (weight, height) User thisUser = entities.UserSettings.OfType<User>().Include("BodyCompositions").FirstOrDefault( u => u.Id == UserSettings.Id ); BodyComposition bc = thisUser.BodyCompositions.FirstOrDefault(); if (bc == null) { bc = new BodyComposition(); bc.UserSetting = thisUser; entities.AddToBodyComposition(bc); } bc.Height = athlete.Height; bc.Weight = athlete.Weight; entities.SaveChanges(); bool loadImg = true; try { Utils.ImageUtil.MakeImageProfilePic(Utils.ImageUtil.ReadImageDataFromUrl(athlete.ImgUrl), UserSettings.Id); } catch (Exception) { loadImg = false; } // next see if we can add them to any groups (via the affiliate) if (athlete.CompetitionAffiliate != null && athlete.CompetitionAffiliate.CFAffiliate != null && athlete.CompetitionAffiliate.CFAffiliate.UserSetting != null) { dataMan.JoinGroup(thisUser.Id, athlete.CompetitionAffiliate.CFAffiliate.UserSetting.Id, ConstsUtil.Relationships.GROUP_MEMBER); } // now add all the games workouts to the site. foreach (CompetitionWOD cw in athlete.CompetitionWODs) { // so far we think they are all AMRAPS dataMan.SaveWorkout(thisUser, (int)Utils.WorkoutUtil.WorkoutType.CROSSFIT, (int)Utils.WorkoutUtil.DataSrc.MANUAL_NO_MAP, DateTime.Now, null, "", true, cw.WOD.Id, cw.Score, null); } if (loadImg) { RadAjaxManager1.ResponseScripts.Add(" Aqufit.Page.Actions.LoadStep(2); "); } else { RadAjaxManager1.ResponseScripts.Add(" Aqufit.Page.Actions.LoadStep(1); "); } break; case "friendRequest": long fid = Convert.ToInt64(hiddenAjaxValue.Value); dataMan.sendFriendRequest(UserSettings.Id, fid); status = "Friend request has been sent."; break; case "joinGroup": long gid = Convert.ToInt64(hiddenAjaxValue.Value); bool isOwner = hiddenAjaxValue2.Value == "true" ? true : false; bool sendRequestToAll = hiddenAjaxValue3.Value == "1" ? true : false; dataMan.JoinGroup(UserSettings.Id, gid, ConstsUtil.Relationships.GROUP_MEMBER); Group group = entities.UserSettings.OfType<Group>().FirstOrDefault(g => g.Id == gid); if (sendRequestToAll) { long[] memberIdArray = entities.UserFriends.Where(g => (g.DestUserSettingKey == gid || g.SrcUserSettingKey == gid) && g.Relationship >= (int)Affine.Utils.ConstsUtil.Relationships.GROUP_OWNER).Select(g => (g.DestUserSettingKey == gid ? g.SrcUserSettingKey : g.DestUserSettingKey)).ToArray(); int numMembers = memberIdArray.Length; foreach (long mid in memberIdArray) { dataMan.sendFriendRequest(UserSettings.Id, mid); } } if (isOwner) { dataMan.makeGroupOwnerRequest(UserSettings as User, group); } if (Request["step"] != null) { // todo: store this owne RadAjaxManager1.ResponseScripts.Add(" Aqufit.Windows.JoinGroupDialog.close(); Aqufit.Page.Actions.LoadStep(4); "); } else { RadAjaxManager1.ResponseScripts.Add(" Aqufit.Windows.JoinGroupDialog.close(); Aqufit.Windows.SuccessDialog.open(\"{'html':'You have been added to the group.'}\");"); } break; case "toggleDotCom": int join = Convert.ToInt32(hiddenAjaxValue.Value); if (join == 1) { dataMan.JoinGroup(UserSettings.Id, CROSSFIT_COM_ID, ConstsUtil.Relationships.GROUP_MEMBER); } else if (join == 0) { dataMan.LeaveGroup(UserSettings.Id, CROSSFIT_COM_ID); } RadAjaxManager1.ResponseScripts.Add("Aqufit.Page.atiLoading.remove(); "); break; } } catch (Exception ex) { status = "ERROR: There was a problem with the action (" + ex.Message + ")"; } RadAjaxManager1.ResponseScripts.Add("UpdateStatus('" + status + "'); "); }
protected void bAjaxPostback_Click(object sender, EventArgs e) { string status = string.Empty; try { Affine.Data.Managers.IDataManager dataMan = Affine.Data.Managers.LINQ.DataManager.Instance; aqufitEntities entities = new aqufitEntities(); switch (hiddenAjaxAction.Value) { case "connectCompAthlete": long aid = Convert.ToInt64(hiddenAjaxValue.Value); CompetitionAthlete athlete = entities.CompetitionAthletes.Include("CompetitionWODs").Include("CompetitionWODs.WOD").Include("CompetitionWODs.WOD.WODType").Include("CompetitionAffiliate").Include("CompetitionAffiliate.CFAffiliate").Include("CompetitionAffiliate.CFAffiliate.UserSetting").FirstOrDefault(a => a.Id == aid); // first lets get any info we can off the profile (weight, height) User thisUser = entities.UserSettings.OfType <User>().Include("BodyCompositions").FirstOrDefault(u => u.Id == UserSettings.Id); BodyComposition bc = thisUser.BodyCompositions.FirstOrDefault(); if (bc == null) { bc = new BodyComposition(); bc.UserSetting = thisUser; entities.AddToBodyComposition(bc); } bc.Height = athlete.Height; bc.Weight = athlete.Weight; entities.SaveChanges(); bool loadImg = true; try { Utils.ImageUtil.MakeImageProfilePic(Utils.ImageUtil.ReadImageDataFromUrl(athlete.ImgUrl), UserSettings.Id); } catch (Exception) { loadImg = false; } // next see if we can add them to any groups (via the affiliate) if (athlete.CompetitionAffiliate != null && athlete.CompetitionAffiliate.CFAffiliate != null && athlete.CompetitionAffiliate.CFAffiliate.UserSetting != null) { dataMan.JoinGroup(thisUser.Id, athlete.CompetitionAffiliate.CFAffiliate.UserSetting.Id, ConstsUtil.Relationships.GROUP_MEMBER); } // now add all the games workouts to the site. foreach (CompetitionWOD cw in athlete.CompetitionWODs) { // so far we think they are all AMRAPS dataMan.SaveWorkout(thisUser, (int)Utils.WorkoutUtil.WorkoutType.CROSSFIT, (int)Utils.WorkoutUtil.DataSrc.MANUAL_NO_MAP, DateTime.Now, null, "", true, cw.WOD.Id, cw.Score, null); } if (loadImg) { RadAjaxManager1.ResponseScripts.Add(" Aqufit.Page.Actions.LoadStep(2); "); } else { RadAjaxManager1.ResponseScripts.Add(" Aqufit.Page.Actions.LoadStep(1); "); } break; case "friendRequest": long fid = Convert.ToInt64(hiddenAjaxValue.Value); dataMan.sendFriendRequest(UserSettings.Id, fid); status = "Friend request has been sent."; break; case "joinGroup": long gid = Convert.ToInt64(hiddenAjaxValue.Value); bool isOwner = hiddenAjaxValue2.Value == "true" ? true : false; bool sendRequestToAll = hiddenAjaxValue3.Value == "1" ? true : false; dataMan.JoinGroup(UserSettings.Id, gid, ConstsUtil.Relationships.GROUP_MEMBER); Group group = entities.UserSettings.OfType <Group>().FirstOrDefault(g => g.Id == gid); if (sendRequestToAll) { long[] memberIdArray = entities.UserFriends.Where(g => (g.DestUserSettingKey == gid || g.SrcUserSettingKey == gid) && g.Relationship >= (int)Affine.Utils.ConstsUtil.Relationships.GROUP_OWNER).Select(g => (g.DestUserSettingKey == gid ? g.SrcUserSettingKey : g.DestUserSettingKey)).ToArray(); int numMembers = memberIdArray.Length; foreach (long mid in memberIdArray) { dataMan.sendFriendRequest(UserSettings.Id, mid); } } if (isOwner) { dataMan.makeGroupOwnerRequest(UserSettings as User, group); } if (Request["step"] != null) { // todo: store this owne RadAjaxManager1.ResponseScripts.Add(" Aqufit.Windows.JoinGroupDialog.close(); Aqufit.Page.Actions.LoadStep(4); "); } else { RadAjaxManager1.ResponseScripts.Add(" Aqufit.Windows.JoinGroupDialog.close(); Aqufit.Windows.SuccessDialog.open(\"{'html':'You have been added to the group.'}\");"); } break; case "toggleDotCom": int join = Convert.ToInt32(hiddenAjaxValue.Value); if (join == 1) { dataMan.JoinGroup(UserSettings.Id, CROSSFIT_COM_ID, ConstsUtil.Relationships.GROUP_MEMBER); } else if (join == 0) { dataMan.LeaveGroup(UserSettings.Id, CROSSFIT_COM_ID); } RadAjaxManager1.ResponseScripts.Add("Aqufit.Page.atiLoading.remove(); "); break; } } catch (Exception ex) { status = "ERROR: There was a problem with the action (" + ex.Message + ")"; } RadAjaxManager1.ResponseScripts.Add("UpdateStatus('" + status + "'); "); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (!string.IsNullOrEmpty(this.ValidationGroupName)) { AddignValidationGroup(this); } atiWeightUnits.UnitList.Add(Affine.Utils.UnitsUtil.MeasureUnit.UNIT_LBS); atiWeightUnits.UnitList.Add(Affine.Utils.UnitsUtil.MeasureUnit.UNIT_KG); atiHeightUnits.UnitList.Add(Affine.Utils.UnitsUtil.MeasureUnit.UNIT_FT_IN); atiHeightUnits.UnitList.Add(Affine.Utils.UnitsUtil.MeasureUnit.UNIT_CM); for (int m = 1; m <= 12; m++) { string month = m < 10 ? "0" + m : "" + m; ddlMonth.Items.Add(new ListItem(month, "" + m)); } for (int d = 1; d <= 31; d++) { ddlDay.Items.Add(new ListItem("" + d, "" + d)); } int thisYear = DateTime.Today.Year; for (int y = 0; y <= 100; y++) { ddlYear.Items.Add(new ListItem("" + (thisYear - y), "" + (thisYear - y))); } if (setBirthday != null) { ddlMonth.SelectedValue = "" + setBirthday.Value.Month; ddlDay.SelectedValue = "" + setBirthday.Value.Day; ddlYear.SelectedValue = "" + setBirthday.Value.Year; } if (this.PortalSettings.UserInfo.UserID != -1) { aqufitEntities aqufitEntities = new aqufitEntities(); UserSettings aqufitSettings = aqufitEntities.UserSettings.FirstOrDefault <UserSettings>(us => us.UserKey == this.PortalSettings.UserInfo.UserID && us.PortalKey == this.PortalSettings.PortalId); if (aqufitSettings == null) // TODO: this really should never happen { aqufitSettings = new User() { UserKey = this.PortalSettings.UserInfo.UserID, PortalKey = this.PortalSettings.PortalId, HeightUnits = (int)Affine.Utils.UnitsUtil.MeasureUnit.UNIT_FT_IN, WeightUnits = (int)Affine.Utils.UnitsUtil.MeasureUnit.UNIT_LBS }; aqufitEntities.AddToUserSettings(aqufitSettings); aqufitEntities.SaveChanges(); } if (aqufitSettings.WeightUnits != null) { atiWeightUnits.Selected = (Affine.Utils.UnitsUtil.MeasureUnit)Enum.ToObject(typeof(Affine.Utils.UnitsUtil.MeasureUnit), aqufitSettings.WeightUnits); } if (aqufitSettings.HeightUnits != null) { atiHeightUnits.Selected = (Affine.Utils.UnitsUtil.MeasureUnit)Enum.ToObject(typeof(Affine.Utils.UnitsUtil.MeasureUnit), aqufitSettings.HeightUnits); } if (atiHeightUnits.Selected == Affine.Utils.UnitsUtil.MeasureUnit.UNIT_CM) { atiTxtHeightFeet.Style["display"] = "none"; rfvHeightFeet.Style["display"] = "none"; revHeightFeet.Style["display"] = "none"; } BodyComposition comp = aqufitEntities.BodyComposition.FirstOrDefault(b => b.UserSetting.Id == aqufitSettings.Id); if (comp != null) { if (comp.Weight.HasValue) { atiTxtWeight.Text = "" + Affine.Utils.UnitsUtil.systemDefaultToUnits(comp.Weight.Value, atiWeightUnits.Selected); } if (comp.Height.HasValue) { if (atiHeightUnits.Selected == Affine.Utils.UnitsUtil.MeasureUnit.UNIT_FT_IN) { double inches = Affine.Utils.UnitsUtil.systemDefaultToUnits(comp.Height.Value, Affine.Utils.UnitsUtil.MeasureUnit.UNIT_INCHES); atiTxtHeightFeet.Text = "" + inches / 12; atiTxtHeightInch.Text = "" + (inches % 12); } else { atiTxtHeightInch.Text = "" + Affine.Utils.UnitsUtil.systemDefaultToUnits(comp.Height.Value, Affine.Utils.UnitsUtil.MeasureUnit.UNIT_CM); } } } } } }
protected void bAjaxPostback_Click(object sender, EventArgs e) { string status = string.Empty; try { Affine.Data.Managers.IDataManager dataMan = Affine.Data.Managers.LINQ.DataManager.Instance; aqufitEntities entities = new aqufitEntities(); switch (hiddenAjaxAction.Value) { case "saveRegistration": CompetitionRegistration registration = null; if (string.IsNullOrWhiteSpace(hiddenAjaxRegistrationId.Value)) { registration = new CompetitionRegistration(); } else { long rId = Convert.ToInt64(hiddenAjaxRegistrationId.Value); registration = entities.CompetitionRegistrations.FirstOrDefault(r => r.Id == rId); } registration.Competition = entities.Competitions.FirstOrDefault(c => c.Id == 1); // ********** TMP User test = entities.UserSettings.OfType <User>().FirstOrDefault(u => u.Id == UserSettings.Id); registration.UserSetting = test; // we have a chance to correct user "miss information" int compType = Convert.ToInt32(ddlCompetitionType.SelectedValue); registration.RegistrationType = compType; registration.DateTime = DateTime.Now; if (!string.IsNullOrWhiteSpace(hiddenAjaxValue.Value)) { long affilId = Convert.ToInt64(hiddenAjaxValue.Value); registration.GroupAffiliate = entities.UserSettings.OfType <Group>().FirstOrDefault(g => g.Id == affilId); } if (compType == 1) { if (atiSlimControl.Email != test.UserEmail) { test.UserEmail = atiSlimControl.Email; } if (atiBodyComp.Gender != test.Sex) { test.Sex = atiBodyComp.Gender; } if (!test.BirthDate.HasValue || atiBodyComp.BirthDate != test.BirthDate.Value) { test.BirthDate = atiBodyComp.BirthDate; } registration.RegistrationType = 1; // individual registration.MailingAddress = txtAddress.Text; registration.ContactPhone = txtPhone.Text; registration.ContactEmail = test.UserEmail; registration.EmergContactName = txtEmergName.Text; registration.EmergContactPhone = txtEmergPhone.Text; registration.EmergContactRelation = txtEmergRelation.Text; registration.ExtraInfo = txtMedical.Text; // save and load the new registration ID entities.SaveChanges(); registration = entities.CompetitionRegistrations.OrderByDescending(r => r.Id).FirstOrDefault(r => r.UserSetting.Id == UserSettings.Id); hiddenAjaxRegistrationId.Value = "" + registration.Id; // now we need to add the users PR's to their profiles... SaveCompWorkoutPR(); } else { // team registration... registration.MailingAddress = txtTeamAddress.Text; registration.ContactPhone = txtTeamPhone.Text; registration.TeamName = txtTeamName.Text; registration.ContactEmail = txtTeamEmail.Text; registration.RegistrationType = 2; // team // save and load the new registration ID entities.SaveChanges(); registration = entities.CompetitionRegistrations.OrderByDescending(r => r.Id).FirstOrDefault(r => r.UserSetting.Id == UserSettings.Id); hiddenAjaxRegistrationId.Value = "" + registration.Id; } RadAjaxManager1.ResponseScripts.Add(" Aqufit.Page.Actions.LoadStep(6); "); break; case "checkTeamLimit": long gId = Convert.ToInt64(hiddenAjaxValue.Value); int count = entities.CompetitionRegistrations.Where(r => r.GroupAffiliate.Id == gId && r.RegistrationType == 2).Count(); // more the 2 affiliate teams alreay ?? if (count >= 2) { Group check = entities.UserSettings.OfType <Group>().FirstOrDefault(g => g.Id == gId); RadAjaxManager1.ResponseScripts.Add(" alert('Sorry the affiliate [ " + check.UserFirstName + " ] already has 2 teams signed up.' );"); } else { RadAjaxManager1.ResponseScripts.Add(" Aqufit.Page.Actions.LoadStep(3);"); } break; case "connectCompAthlete": long aid = Convert.ToInt64(hiddenAjaxValue.Value); CompetitionAthlete athlete = entities.CompetitionAthletes.Include("CompetitionWODs").Include("CompetitionWODs.WOD").Include("CompetitionWODs.WOD.WODType").Include("CompetitionAffiliate").Include("CompetitionAffiliate.CFAffiliate").Include("CompetitionAffiliate.CFAffiliate.UserSetting").FirstOrDefault(a => a.Id == aid); // first lets get any info we can off the profile (weight, height) User thisUser = entities.UserSettings.OfType <User>().Include("BodyCompositions").FirstOrDefault(u => u.Id == UserSettings.Id); BodyComposition bc = thisUser.BodyCompositions.FirstOrDefault(); if (bc == null) { bc = new BodyComposition(); bc.UserSetting = thisUser; entities.AddToBodyComposition(bc); } bc.Height = athlete.Height; bc.Weight = athlete.Weight; entities.SaveChanges(); bool loadImg = true; try { Utils.ImageUtil.MakeImageProfilePic(Utils.ImageUtil.ReadImageDataFromUrl(athlete.ImgUrl), UserSettings.Id); } catch (Exception) { loadImg = false; } // next see if we can add them to any groups (via the affiliate) if (athlete.CompetitionAffiliate != null && athlete.CompetitionAffiliate.CFAffiliate != null && athlete.CompetitionAffiliate.CFAffiliate.UserSetting != null) { dataMan.JoinGroup(thisUser.Id, athlete.CompetitionAffiliate.CFAffiliate.UserSetting.Id, ConstsUtil.Relationships.GROUP_MEMBER); } // now add all the games workouts to the site. foreach (CompetitionWOD cw in athlete.CompetitionWODs) { // so far we think they are all AMRAPS dataMan.SaveWorkout(thisUser, (int)Utils.WorkoutUtil.WorkoutType.CROSSFIT, (int)Utils.WorkoutUtil.DataSrc.MANUAL_NO_MAP, DateTime.Now, null, "", true, cw.WOD.Id, cw.Score, null); } if (loadImg) { RadAjaxManager1.ResponseScripts.Add(" Aqufit.Page.Actions.LoadStep(2); "); } else { RadAjaxManager1.ResponseScripts.Add(" Aqufit.Page.Actions.LoadStep(1); "); } break; case "friendRequest": long fid = Convert.ToInt64(hiddenAjaxValue.Value); dataMan.sendFriendRequest(UserSettings.Id, fid); status = "Friend request has been sent."; break; case "joinGroup": long gid = Convert.ToInt64(hiddenAjaxValue.Value); bool isOwner = hiddenAjaxValue2.Value == "true" ? true : false; bool sendRequestToAll = hiddenAjaxValue3.Value == "1" ? true : false; dataMan.JoinGroup(UserSettings.Id, gid, ConstsUtil.Relationships.GROUP_MEMBER); Group group = entities.UserSettings.OfType <Group>().FirstOrDefault(g => g.Id == gid); if (sendRequestToAll) { long[] memberIdArray = entities.UserFriends.Where(g => (g.DestUserSettingKey == gid || g.SrcUserSettingKey == gid) && g.Relationship >= (int)Affine.Utils.ConstsUtil.Relationships.GROUP_OWNER).Select(g => (g.DestUserSettingKey == gid ? g.SrcUserSettingKey : g.DestUserSettingKey)).ToArray(); int numMembers = memberIdArray.Length; foreach (long mid in memberIdArray) { dataMan.sendFriendRequest(UserSettings.Id, mid); } } if (isOwner) { dataMan.makeGroupOwnerRequest(UserSettings as User, group); } if (Request["step"] != null) { // todo: store this owne RadAjaxManager1.ResponseScripts.Add(" Aqufit.Windows.JoinGroupDialog.close(); Aqufit.Page.Actions.LoadStep(4); "); } else { RadAjaxManager1.ResponseScripts.Add(" Aqufit.Windows.JoinGroupDialog.close(); Aqufit.Windows.SuccessDialog.open(\"{'html':'You have been added to the group.'}\");"); } break; } } catch (Exception ex) { status = "ERROR: There was a problem with the action (" + ex.Message + ex.StackTrace.Replace("'", "").Replace("\n", "") + ")"; RadAjaxManager1.ResponseScripts.Add("alert('" + status + "'); "); } }
protected void bBodyComposition_Click(object sender, EventArgs e) { // TODO: check inputs for error UserSettings userSettings = new UserSettings(); if (atiBodyComposition.BirthDate == null) { lErrorText.Text = "You must enter your Birthdate."; return; } if (string.IsNullOrEmpty( atiBodyComposition.Weight )) { lErrorText.Text = "You must enter your weight."; return; } userSettings.BirthDate = Convert.ToDateTime(atiBodyComposition.BirthDate); //userSettings.DistanceUnits = (short)atiBodyComposition.DistanceUnits; userSettings.HeightUnits = (short)atiBodyComposition.HeightUnits; userSettings.WeightUnits = (short)atiBodyComposition.WeightUnits; userSettings.UserKey = UserId; userSettings.PortalKey = PortalId; userSettings.Sex = atiBodyComposition.Gender; aqufitEntities aqufitEntities = new aqufitEntities(); aqufitEntities.AddToUserSettings(userSettings); BodyComposition bc = new BodyComposition() { UserKey = UserId, PortalKey = PortalId, FitnessLevel = atiBodyComposition.FitnessLevel }; // need height and weight conversions bc.Modified = DateTime.Now; bc.BodyFatPercent = 0.0; bc.Weight = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyComposition.Weight), atiBodyComposition.WeightUnits); // bc.Height = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyComposition.Height), atiBodyComposition.HeightUnits); aqufitEntities.AddToBodyComposition(bc); BodyMeasurments bm = new BodyMeasurments() { UserKey = UserId, PortalKey = PortalId }; Affine.Utils.UnitsUtil.MeasureUnit bmUnits = atiBodyComposition.HeightUnits == Affine.Utils.UnitsUtil.MeasureUnit.UNIT_INCHES ? Affine.Utils.UnitsUtil.MeasureUnit.UNIT_INCHES : Affine.Utils.UnitsUtil.MeasureUnit.UNIT_CM; if (!string.IsNullOrEmpty(atiBodyMeasurements.Chest)) bm.Chest = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyMeasurements.Chest), bmUnits); if (!string.IsNullOrEmpty(atiBodyMeasurements.Neck)) bm.Neck = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyMeasurements.Neck), bmUnits); if (!string.IsNullOrEmpty(atiBodyMeasurements.Shoulders)) bm.Shoulders = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyMeasurements.Shoulders), bmUnits); if (!string.IsNullOrEmpty(atiBodyMeasurements.Stomach)) bm.Stomach = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyMeasurements.Stomach), bmUnits); if (!string.IsNullOrEmpty(atiBodyMeasurements.Waist)) bm.Waist = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyMeasurements.Waist), bmUnits); if (!string.IsNullOrEmpty(atiBodyMeasurements.Hips)) bm.Hips = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyMeasurements.Hips), bmUnits); if (!string.IsNullOrEmpty(atiBodyMeasurements.BicepLeft)) bm.BicepLeft = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyMeasurements.BicepLeft), bmUnits); if (!string.IsNullOrEmpty(atiBodyMeasurements.BicepRight)) bm.BicepRight = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyMeasurements.BicepRight), bmUnits); if (!string.IsNullOrEmpty(atiBodyMeasurements.ForearmLeft)) bm.ForearmLeft = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyMeasurements.ForearmLeft), bmUnits); if (!string.IsNullOrEmpty(atiBodyMeasurements.ForearmRight)) bm.ForearmRight = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyMeasurements.ForearmRight), bmUnits); if (!string.IsNullOrEmpty(atiBodyMeasurements.ThighLeft)) bm.ThighLeft = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyMeasurements.ThighLeft), bmUnits); if (!string.IsNullOrEmpty(atiBodyMeasurements.ThighRight)) bm.ThighRight = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyMeasurements.ThighRight), bmUnits); if (!string.IsNullOrEmpty(atiBodyMeasurements.CalfLeft)) bm.CalfLeft = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyMeasurements.CalfLeft), bmUnits); if (!string.IsNullOrEmpty(atiBodyMeasurements.CalfLeft)) bm.CalfRight = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyMeasurements.CalfRight), bmUnits); bm.Modified = DateTime.Now; aqufitEntities.AddToBodyMeasurments(bm); aqufitEntities.SaveChanges(); bBodyComposition.Visible = false; bProfile.Visible = true; RadAjaxManager1.ResponseScripts.Add("AjaxResponseSuccess();"); }
protected void bBodyComposition_Click(object sender, EventArgs e) { // TODO: check inputs for error UserSettings userSettings = new UserSettings(); if (atiBodyComposition.BirthDate == null) { lErrorText.Text = "You must enter your Birthdate."; return; } if (string.IsNullOrEmpty(atiBodyComposition.Weight)) { lErrorText.Text = "You must enter your weight."; return; } userSettings.BirthDate = Convert.ToDateTime(atiBodyComposition.BirthDate); //userSettings.DistanceUnits = (short)atiBodyComposition.DistanceUnits; userSettings.HeightUnits = (short)atiBodyComposition.HeightUnits; userSettings.WeightUnits = (short)atiBodyComposition.WeightUnits; userSettings.UserKey = UserId; userSettings.PortalKey = PortalId; userSettings.Sex = atiBodyComposition.Gender; aqufitEntities aqufitEntities = new aqufitEntities(); aqufitEntities.AddToUserSettings(userSettings); BodyComposition bc = new BodyComposition() { UserKey = UserId, PortalKey = PortalId, FitnessLevel = atiBodyComposition.FitnessLevel }; // need height and weight conversions bc.Modified = DateTime.Now; bc.BodyFatPercent = 0.0; bc.Weight = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyComposition.Weight), atiBodyComposition.WeightUnits); // bc.Height = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyComposition.Height), atiBodyComposition.HeightUnits); aqufitEntities.AddToBodyComposition(bc); BodyMeasurments bm = new BodyMeasurments() { UserKey = UserId, PortalKey = PortalId }; Affine.Utils.UnitsUtil.MeasureUnit bmUnits = atiBodyComposition.HeightUnits == Affine.Utils.UnitsUtil.MeasureUnit.UNIT_INCHES ? Affine.Utils.UnitsUtil.MeasureUnit.UNIT_INCHES : Affine.Utils.UnitsUtil.MeasureUnit.UNIT_CM; if (!string.IsNullOrEmpty(atiBodyMeasurements.Chest)) { bm.Chest = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyMeasurements.Chest), bmUnits); } if (!string.IsNullOrEmpty(atiBodyMeasurements.Neck)) { bm.Neck = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyMeasurements.Neck), bmUnits); } if (!string.IsNullOrEmpty(atiBodyMeasurements.Shoulders)) { bm.Shoulders = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyMeasurements.Shoulders), bmUnits); } if (!string.IsNullOrEmpty(atiBodyMeasurements.Stomach)) { bm.Stomach = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyMeasurements.Stomach), bmUnits); } if (!string.IsNullOrEmpty(atiBodyMeasurements.Waist)) { bm.Waist = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyMeasurements.Waist), bmUnits); } if (!string.IsNullOrEmpty(atiBodyMeasurements.Hips)) { bm.Hips = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyMeasurements.Hips), bmUnits); } if (!string.IsNullOrEmpty(atiBodyMeasurements.BicepLeft)) { bm.BicepLeft = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyMeasurements.BicepLeft), bmUnits); } if (!string.IsNullOrEmpty(atiBodyMeasurements.BicepRight)) { bm.BicepRight = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyMeasurements.BicepRight), bmUnits); } if (!string.IsNullOrEmpty(atiBodyMeasurements.ForearmLeft)) { bm.ForearmLeft = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyMeasurements.ForearmLeft), bmUnits); } if (!string.IsNullOrEmpty(atiBodyMeasurements.ForearmRight)) { bm.ForearmRight = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyMeasurements.ForearmRight), bmUnits); } if (!string.IsNullOrEmpty(atiBodyMeasurements.ThighLeft)) { bm.ThighLeft = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyMeasurements.ThighLeft), bmUnits); } if (!string.IsNullOrEmpty(atiBodyMeasurements.ThighRight)) { bm.ThighRight = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyMeasurements.ThighRight), bmUnits); } if (!string.IsNullOrEmpty(atiBodyMeasurements.CalfLeft)) { bm.CalfLeft = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyMeasurements.CalfLeft), bmUnits); } if (!string.IsNullOrEmpty(atiBodyMeasurements.CalfLeft)) { bm.CalfRight = Affine.Utils.UnitsUtil.unitsToSystemDefualt(Convert.ToDouble(atiBodyMeasurements.CalfRight), bmUnits); } bm.Modified = DateTime.Now; aqufitEntities.AddToBodyMeasurments(bm); aqufitEntities.SaveChanges(); bBodyComposition.Visible = false; bProfile.Visible = true; RadAjaxManager1.ResponseScripts.Add("AjaxResponseSuccess();"); }
internal static BodyCompositionExpanded Build(BodyComposition bodyComposition, double visceralFat, double percentBodyFat) { return(new BodyCompositionExpanded(bodyComposition, visceralFat, percentBodyFat)); }
protected BodyCompositionBaseClassification(BodyComposition bodyComposition, Patient patient) { _bodyComposition = bodyComposition ?? throw new ArgumentNullException(nameof(bodyComposition)); _patient = patient ?? throw new ArgumentNullException(nameof(patient)); }
protected void bUserSetup_Click(object sender, EventArgs e) { if (Page.IsValid) { int UID = -1; UserInfo objUserInfo = UserController.GetUserByName(PortalId, atiUserNameSetup.Text); // if a user is found with that username, error. this prevents you from adding a username with the same name as a superuser. if (objUserInfo != null) { RadAjaxManager1.ResponseScripts.Add("Aqufit.Windows.ErrorDialog.open('{\"html\":\"We already have an entry for the User Name.\"}');"); return; } else if (string.IsNullOrWhiteSpace(atiSlimFBSetup.Postal)) { RadAjaxManager1.ResponseScripts.Add("Aqufit.Windows.ErrorDialog.open('{\"html\":\"Postal/Zip is required to give you accurate gym, route, and user information, in your location.\"}');"); return; } else if (atiPasswordSetup.Password != atiPasswordSetup.Confirm) { RadAjaxManager1.ResponseScripts.Add("Aqufit.Windows.ErrorDialog.open('{\"html\":\"Password and Confirmation do not match.\"}');"); return; } Affine.WebService.RegisterService regService = new WebService.RegisterService(); UserInfo objNewUser = regService.InitialiseUser(PortalId); // TODO: this method // TODO: need a TimeZone control string fname = hiddenGivenName.Value; string lname = hiddenFamilyName.Value; string fullname = fname + " " + lname; //string uuid = Guid.NewGuid().ToString().Substring(0, 15); string pass = atiPasswordSetup.Password; string email = hiddenEmail.Value; regService.populateDnnUserInfo(PortalId, ref objNewUser, fname, lname, atiUserNameSetup.Text, email, pass, atiSlimFBSetup.Postal, atiSlimFBSetup.Address, null); DotNetNuke.Security.Membership.UserCreateStatus userCreateStatus = UserController.CreateUser(ref objNewUser); if (userCreateStatus == DotNetNuke.Security.Membership.UserCreateStatus.Success) { UID = objNewUser.UserID; // DNN3 BUG DotNetNuke.Services.Log.EventLog.EventLogController objEventLog = new DotNetNuke.Services.Log.EventLog.EventLogController(); objEventLog.AddLog(objNewUser, PortalSettings, objNewUser.UserID, atiSlimControl.Email, DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.USER_CREATED); // send notification to portal administrator of new user registration // DotNetNuke.Services.Mail.Mail.SendMail(objNewUser, DotNetNuke.Services.Mail.MessageType.UserRegistrationAdmin, PortalSettings); // DotNetNuke.Services.Mail.Mail.SendMail(objNewUser, DotNetNuke.Services.Mail.MessageType.UserRegistrationPublic, PortalSettings); DataCache.ClearUserCache(PortalId, objNewUser.Username); UserController.UserLogin(PortalId, objNewUser, PortalSettings.PortalName, DotNetNuke.Services.Authentication.AuthenticationLoginBase.GetIPAddress(), true); User us = new Data.User(); us = (User)populateUserSettings(us, objNewUser); try { us.FBUid = Convert.ToInt64(hiddenIdentifier.Value); } catch (Exception) { } entities.AddToUserSettings(us); entities.SaveChanges(); // TODO: should have a populate function for these BodyComposition bc = new BodyComposition() { UserSetting = us }; if (atiBodyComp.Visible && atiBodyComp.FitnessLevelVisible) { bc.FitnessLevel = atiBodyComp.FitnessLevel; } // need height and weight conversions if (atiBodyComp.Visible && atiBodyComp.WeightVisible) { bc.Weight = atiBodyComp.UserWeightInSystemDefault; } if (atiBodyComp.Visible && atiBodyComp.HeightVisible) { bc.Height = atiBodyComp.UserHeightInSystemDefault; } entities.AddToBodyComposition(bc); entities.SaveChanges(); string body = "User registration recorded\n\n"; body += "ID: " + objNewUser.UserID + "\n"; body += "User: "******"\n"; body += "First Name: " + objNewUser.FirstName + "\n"; body += "Last Name: " + objNewUser.LastName + "\n"; body += "Email: " + objNewUser.Email + "\n"; body += "Portal: " + objNewUser.PortalID + "\n"; // DotNetNuke.Services.Mail.Mail.SendMail("*****@*****.**", "*****@*****.**", "", "NEW aqufit.com USER", body, "", "HTML", "", "", "", ""); Affine.Utils.GmailUtil gmail = new Utils.GmailUtil(); gmail.Send("*****@*****.**", "User Signup: " + objNewUser.Username, body); // See if this person was invited by anyone. ContactInvite invite = entities.ContactInvites.Include("UserSetting").FirstOrDefault(i => i.Email == us.UserEmail); if (invite != null) { // this person was invited by someone so lets make them friends.... string stat = Affine.Data.Managers.LINQ.DataManager.Instance.AcceptFriendRequests(invite.UserSetting.Id, us.Id); // TODO: assume success send for now } Response.Redirect(Convert.ToString(Settings["LandingPage"]), true); } else { // registration error string body = "User registration FAILED \n\n"; body += "ID: " + objNewUser.UserID + "\n"; body += "User: "******"\n"; body += "First Name: " + fname + "\n"; body += "Last Name: " + lname + "\n"; body += "Email: " + email + "\n"; body += "Status: " + userCreateStatus.ToString(); // string errStr = userCreateStatus.ToString() + "\n\n" + atiSlimControl.ToString(); // DotNetNuke.Services.Mail.Mail.SendMail("*****@*****.**", "*****@*****.**", "", "FAILED REGISTRATION", lErrorText.Text + errStr, "", "HTML", "", "", "", ""); Affine.Utils.GmailUtil gmail = new Utils.GmailUtil(); gmail.Send("*****@*****.**", "**FAIL** RPX User Signup: " + objNewUser.Username, body); RadAjaxManager1.ResponseScripts.Add("Aqufit.Windows.ErrorDialog.open('{\"html\":\"" + userCreateStatus.ToString() + "\"}');"); } } else { RadAjaxManager1.ResponseScripts.Add("Aqufit.Windows.ErrorDialog.open('{\"html\":\"\"}');"); } }
protected void bAjaxPostback_Click(object sender, EventArgs e) { string status = string.Empty; try { Affine.Data.Managers.IDataManager dataMan = Affine.Data.Managers.LINQ.DataManager.Instance; aqufitEntities entities = new aqufitEntities(); switch (hiddenAjaxAction.Value) { case "saveRegistration": CompetitionRegistration registration = null; if (string.IsNullOrWhiteSpace(hiddenAjaxRegistrationId.Value)) { registration = new CompetitionRegistration(); } else { long rId = Convert.ToInt64(hiddenAjaxRegistrationId.Value); registration = entities.CompetitionRegistrations.FirstOrDefault(r => r.Id == rId); } registration.Competition = entities.Competitions.FirstOrDefault( c => c.Id == 1 ); // ********** TMP User test = entities.UserSettings.OfType<User>().FirstOrDefault(u => u.Id == UserSettings.Id); registration.UserSetting = test; // we have a chance to correct user "miss information" int compType = Convert.ToInt32( ddlCompetitionType.SelectedValue ); registration.RegistrationType = compType; registration.DateTime = DateTime.Now; if (!string.IsNullOrWhiteSpace(hiddenAjaxValue.Value)) { long affilId = Convert.ToInt64(hiddenAjaxValue.Value); registration.GroupAffiliate = entities.UserSettings.OfType<Group>().FirstOrDefault(g => g.Id == affilId); } if (compType == 1) { if (atiSlimControl.Email != test.UserEmail) test.UserEmail = atiSlimControl.Email; if (atiBodyComp.Gender != test.Sex) test.Sex = atiBodyComp.Gender; if (!test.BirthDate.HasValue || atiBodyComp.BirthDate != test.BirthDate.Value) test.BirthDate = atiBodyComp.BirthDate; registration.RegistrationType = 1; // individual registration.MailingAddress = txtAddress.Text; registration.ContactPhone = txtPhone.Text; registration.ContactEmail = test.UserEmail; registration.EmergContactName = txtEmergName.Text; registration.EmergContactPhone = txtEmergPhone.Text; registration.EmergContactRelation = txtEmergRelation.Text; registration.ExtraInfo = txtMedical.Text; // save and load the new registration ID entities.SaveChanges(); registration = entities.CompetitionRegistrations.OrderByDescending(r => r.Id).FirstOrDefault(r => r.UserSetting.Id == UserSettings.Id); hiddenAjaxRegistrationId.Value = "" + registration.Id; // now we need to add the users PR's to their profiles... SaveCompWorkoutPR(); } else { // team registration... registration.MailingAddress = txtTeamAddress.Text; registration.ContactPhone = txtTeamPhone.Text; registration.TeamName = txtTeamName.Text; registration.ContactEmail = txtTeamEmail.Text; registration.RegistrationType = 2; // team // save and load the new registration ID entities.SaveChanges(); registration = entities.CompetitionRegistrations.OrderByDescending(r => r.Id).FirstOrDefault(r => r.UserSetting.Id == UserSettings.Id); hiddenAjaxRegistrationId.Value = "" + registration.Id; } RadAjaxManager1.ResponseScripts.Add(" Aqufit.Page.Actions.LoadStep(6); "); break; case "checkTeamLimit": long gId = Convert.ToInt64(hiddenAjaxValue.Value); int count = entities.CompetitionRegistrations.Where(r => r.GroupAffiliate.Id == gId && r.RegistrationType == 2 ).Count(); // more the 2 affiliate teams alreay ?? if (count >= 2) { Group check = entities.UserSettings.OfType<Group>().FirstOrDefault( g => g.Id == gId ); RadAjaxManager1.ResponseScripts.Add(" alert('Sorry the affiliate [ " + check.UserFirstName + " ] already has 2 teams signed up.' );" ); } else { RadAjaxManager1.ResponseScripts.Add(" Aqufit.Page.Actions.LoadStep(3);"); } break; case "connectCompAthlete": long aid = Convert.ToInt64(hiddenAjaxValue.Value); CompetitionAthlete athlete = entities.CompetitionAthletes.Include("CompetitionWODs").Include("CompetitionWODs.WOD").Include("CompetitionWODs.WOD.WODType").Include("CompetitionAffiliate").Include("CompetitionAffiliate.CFAffiliate").Include("CompetitionAffiliate.CFAffiliate.UserSetting").FirstOrDefault(a => a.Id == aid); // first lets get any info we can off the profile (weight, height) User thisUser = entities.UserSettings.OfType<User>().Include("BodyCompositions").FirstOrDefault( u => u.Id == UserSettings.Id ); BodyComposition bc = thisUser.BodyCompositions.FirstOrDefault(); if (bc == null) { bc = new BodyComposition(); bc.UserSetting = thisUser; entities.AddToBodyComposition(bc); } bc.Height = athlete.Height; bc.Weight = athlete.Weight; entities.SaveChanges(); bool loadImg = true; try { Utils.ImageUtil.MakeImageProfilePic(Utils.ImageUtil.ReadImageDataFromUrl(athlete.ImgUrl), UserSettings.Id); } catch (Exception) { loadImg = false; } // next see if we can add them to any groups (via the affiliate) if (athlete.CompetitionAffiliate != null && athlete.CompetitionAffiliate.CFAffiliate != null && athlete.CompetitionAffiliate.CFAffiliate.UserSetting != null) { dataMan.JoinGroup(thisUser.Id, athlete.CompetitionAffiliate.CFAffiliate.UserSetting.Id, ConstsUtil.Relationships.GROUP_MEMBER); } // now add all the games workouts to the site. foreach (CompetitionWOD cw in athlete.CompetitionWODs) { // so far we think they are all AMRAPS dataMan.SaveWorkout(thisUser, (int)Utils.WorkoutUtil.WorkoutType.CROSSFIT, (int)Utils.WorkoutUtil.DataSrc.MANUAL_NO_MAP, DateTime.Now, null, "", true, cw.WOD.Id, cw.Score, null); } if (loadImg) { RadAjaxManager1.ResponseScripts.Add(" Aqufit.Page.Actions.LoadStep(2); "); } else { RadAjaxManager1.ResponseScripts.Add(" Aqufit.Page.Actions.LoadStep(1); "); } break; case "friendRequest": long fid = Convert.ToInt64(hiddenAjaxValue.Value); dataMan.sendFriendRequest(UserSettings.Id, fid); status = "Friend request has been sent."; break; case "joinGroup": long gid = Convert.ToInt64(hiddenAjaxValue.Value); bool isOwner = hiddenAjaxValue2.Value == "true" ? true : false; bool sendRequestToAll = hiddenAjaxValue3.Value == "1" ? true : false; dataMan.JoinGroup(UserSettings.Id, gid, ConstsUtil.Relationships.GROUP_MEMBER); Group group = entities.UserSettings.OfType<Group>().FirstOrDefault(g => g.Id == gid); if (sendRequestToAll) { long[] memberIdArray = entities.UserFriends.Where(g => (g.DestUserSettingKey == gid || g.SrcUserSettingKey == gid) && g.Relationship >= (int)Affine.Utils.ConstsUtil.Relationships.GROUP_OWNER).Select(g => (g.DestUserSettingKey == gid ? g.SrcUserSettingKey : g.DestUserSettingKey)).ToArray(); int numMembers = memberIdArray.Length; foreach (long mid in memberIdArray) { dataMan.sendFriendRequest(UserSettings.Id, mid); } } if (isOwner) { dataMan.makeGroupOwnerRequest(UserSettings as User, group); } if (Request["step"] != null) { // todo: store this owne RadAjaxManager1.ResponseScripts.Add(" Aqufit.Windows.JoinGroupDialog.close(); Aqufit.Page.Actions.LoadStep(4); "); } else { RadAjaxManager1.ResponseScripts.Add(" Aqufit.Windows.JoinGroupDialog.close(); Aqufit.Windows.SuccessDialog.open(\"{'html':'You have been added to the group.'}\");"); } break; } } catch (Exception ex) { status = "ERROR: There was a problem with the action (" + ex.Message + ex.StackTrace.Replace("'","").Replace("\n","")+")"; RadAjaxManager1.ResponseScripts.Add("alert('" + status + "'); "); } }
public BodyCompositionClassificationParameters(BodyComposition bodyComposition, Patient patient) { BodyComposition = bodyComposition; Patient = patient; }
private UserSettings populateUserSettings(UserSettings us, UserInfo ui) { aqufitEntities entities = new aqufitEntities(); long usId = us.Id; us.UserKey = ui.UserID; us.PortalKey = ui.PortalID; us.UserEmail = ui.Email; us.UserName = ui.Username; us.UserFirstName = ui.FirstName; us.UserLastName = ui.LastName; //us.TimeZone = ui.Profile.TimeZone; if (atiBodyComp.Visible) { if (atiBodyComp.GenderVisible) { us.Sex = atiBodyComp.Gender; } if (atiBodyComp.BirthDateVisible && atiBodyComp.BirthDate.HasValue) { us.BirthDate = Convert.ToDateTime(atiBodyComp.BirthDate); } if (atiBodyComp.WeightVisible) { us.WeightUnits = Convert.ToInt16(atiBodyComp.WeightUnits); } if (atiBodyComp.HeightVisible) { us.HeightUnits = Convert.ToInt16(atiBodyComp.HeightUnits); } } if (ddlHomeGroup.Items.Count > 0 ) { us.MainGroupKey = Convert.ToInt64( ddlHomeGroup.SelectedValue ); } if (atiHeightWeight.Visible) { BodyComposition bc = entities.BodyComposition.FirstOrDefault(b => b.UserSetting.Id == us.Id); if( bc == null ){ bc = new BodyComposition(){ UserSetting = entities.UserSettings.FirstOrDefault( u => u.Id == us.Id ), }; entities.AddToBodyComposition(bc); } if (atiHeightWeight.WeightVisible) { bc.Weight = atiHeightWeight.UserWeightInSystemDefault; } if (atiHeightWeight.HeightVisible) { bc.Height = atiHeightWeight.UserHeightInSystemDefault; } bc.Bio = txtBio.Text; bc.Description = txtTraining.Text; entities.SaveChanges(); } ASP.desktopmodules_ati_base_controls_ati_slimcontrol_ascx slim = atiSlimControl.Visible ? atiSlimControl : (atiSlimFBSetup.Visible ? atiSlimFBSetup : null); if (slim != null) { if (!string.IsNullOrEmpty(slim.LocLat)) { us.DefaultMapLat = Convert.ToDouble(slim.LocLat); us.LatHome = us.DefaultMapLat; } if (!string.IsNullOrEmpty(slim.LocLng)) { us.DefaultMapLng = Convert.ToDouble(slim.LocLng); us.LngHome = us.DefaultMapLng; } us.RemoteAddress = slim.Address; } UserSettingsExtended[] webLinks = entities.UserSettingsExtendeds.Where(s => s.UserSetting.Id == usId && s.Class == 1).ToArray(); if (atiWebLinks.Visible) { // Facebook UserSettingsExtended facebook = webLinks.FirstOrDefault(s => s.Name == "Facebook"); if (!string.IsNullOrEmpty(atiWebLinks.Facebook)) { if (facebook == null) { facebook = new UserSettingsExtended() { Class = 1, Name = "Facebook", Value = atiWebLinks.Facebook }; us.UserSettingsExtendeds.Add(facebook); } else { facebook.Value = atiWebLinks.Facebook; } } else if (facebook != null) { entities.DeleteObject(facebook); } // Twitter UserSettingsExtended twitter = webLinks.FirstOrDefault(s => s.Name == "Twitter"); if (!string.IsNullOrEmpty(atiWebLinks.Twitter)) { if (twitter == null) { twitter = new UserSettingsExtended() { Class = 1, Name = "Twitter", Value = atiWebLinks.Twitter }; us.UserSettingsExtendeds.Add(twitter); } else { twitter.Value = atiWebLinks.Twitter; } } else if (twitter != null) { entities.DeleteObject(twitter); } // YouTube UserSettingsExtended youtube = webLinks.FirstOrDefault(s => s.Name == "YouTube"); if (!string.IsNullOrEmpty(atiWebLinks.YouTube)) { if (youtube == null) { youtube = new UserSettingsExtended() { Class = 1, Name = "YouTube", Value = atiWebLinks.YouTube }; us.UserSettingsExtendeds.Add(youtube); } else { youtube.Value = atiWebLinks.YouTube; } } else if (youtube != null) { entities.DeleteObject(youtube); } // LinkedIn UserSettingsExtended linkedin = webLinks.FirstOrDefault(s => s.Name == "LinkedIn"); if (!string.IsNullOrEmpty(atiWebLinks.LinkedIn)) { if (linkedin == null) { linkedin = new UserSettingsExtended() { Class = 1, Name = "LinkedIn", Value = atiWebLinks.LinkedIn }; us.UserSettingsExtendeds.Add(linkedin); } else { linkedin.Value = atiWebLinks.LinkedIn; } } else if (linkedin != null) { entities.DeleteObject(linkedin); } // Flickr UserSettingsExtended flickr = webLinks.FirstOrDefault(s => s.Name == "Flickr"); if (!string.IsNullOrEmpty(atiWebLinks.Flickr)) { if (flickr == null) { flickr = new UserSettingsExtended() { Class = 1, Name = "Flickr", Value = atiWebLinks.Flickr }; us.UserSettingsExtendeds.Add(flickr); } else { flickr.Value = atiWebLinks.Flickr; } } else if (flickr != null) { entities.DeleteObject(flickr); } // Personal UserSettingsExtended personal = webLinks.FirstOrDefault(s => s.Name == "Personal"); if (!string.IsNullOrEmpty(atiWebLinks.Peronsal)) { if (personal == null) { personal = new UserSettingsExtended() { Class = 1, Name = "Personal", Value = atiWebLinks.Peronsal }; us.UserSettingsExtendeds.Add(personal); } else { personal.Value = atiWebLinks.Peronsal; } } else if (personal != null) { entities.DeleteObject(personal); } entities.SaveChanges(); } return us; }
private static double Calculate(BodyComposition bodyComposition) { return(bodyComposition.Waist.Centimeters / bodyComposition.Height.Centimeters); }
private bool Register() { //Try // Only attempt a save/update if all form fields on the page are valid if (Page.IsValid) { // check required fields int UID = -1; UserInfo objUserInfo = UserController.GetUserByName(PortalId, atiUserName.Text); // if a user is found with that username, error. this prevents you from adding a username with the same name as a superuser. if (objUserInfo != null) { RadAjaxManager1.ResponseScripts.Add("Aqufit.Windows.ErrorDialog.open('{\"html\":\"We already have an entry for the User Name.\"}');"); return false; } Affine.WebService.RegisterService regService = new WebService.RegisterService(); double? timezone = null; if (!string.IsNullOrEmpty(atiSlimControl.LocLat)) { // timezone = regService.GetTimeZone(Convert.ToDouble(atiSlimControl.LocLat), Convert.ToDouble(atiSlimControl.LocLng)); } UserInfo objNewUser = regService.InitialiseUser(PortalId); string fullname = atiSlimControl.FullName; string[] nameparts = fullname.Split(' '); string fname = string.Empty; string lname = string.Empty; if (nameparts.Length >= 2) { fname = nameparts[0]; lname = nameparts[1]; } regService.populateDnnUserInfo(PortalId, ref objNewUser, fname, lname, atiUserName.Text, atiSlimControl.Email, atiPassword.Password, atiSlimControl.Postal, atiSlimControl.Address, timezone); DotNetNuke.Security.Membership.UserCreateStatus userCreateStatus = UserController.CreateUser(ref objNewUser); if (userCreateStatus == DotNetNuke.Security.Membership.UserCreateStatus.Success) { UID = objNewUser.UserID; // DNN3 BUG DotNetNuke.Services.Log.EventLog.EventLogController objEventLog = new DotNetNuke.Services.Log.EventLog.EventLogController(); objEventLog.AddLog(objNewUser, PortalSettings, objNewUser.UserID, atiSlimControl.Email, DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.USER_CREATED); // send notification to portal administrator of new user registration // DotNetNuke.Services.Mail.Mail.SendMail(objNewUser, DotNetNuke.Services.Mail.MessageType.UserRegistrationAdmin, PortalSettings); // DotNetNuke.Services.Mail.Mail.SendMail(objNewUser, DotNetNuke.Services.Mail.MessageType.UserRegistrationPublic, PortalSettings); DataCache.ClearUserCache(PortalId, objNewUser.Username); UserController.UserLogin(PortalId, objNewUser, PortalSettings.PortalName, DotNetNuke.Services.Authentication.AuthenticationLoginBase.GetIPAddress(), true); User us = new Data.User(); us = (User)populateUserSettings(us, objNewUser); if (atiBodyComp.BirthDateVisible) { us.BirthDate = atiBodyComp.BirthDate; } SiteSetting tutorial = new SiteSetting() { UserSetting = us, Name = "SiteIntro", Value = "1" }; entities.AddToUserSettings(us); entities.SaveChanges(); us = entities.UserSettings.OfType<User>().FirstOrDefault( u => u.UserKey == objNewUser.UserID && u.PortalKey == objNewUser.PortalID ); // TODO: should have a populate function for these BodyComposition bc = new BodyComposition() { UserSetting = us }; if (atiBodyComp.FitnessLevelVisible) { bc.FitnessLevel = atiBodyComp.FitnessLevel; } // need height and weight conversions if (atiBodyComp.WeightVisible) { bc.Weight = atiBodyComp.UserWeightInSystemDefault; } if( atiBodyComp.HeightVisible ) { bc.Height = atiBodyComp.UserHeightInSystemDefault; } entities.AddToBodyComposition(bc); entities.SaveChanges(); string body = "User registration recorded\n\n"; body += "ID: " + objNewUser.UserID + "\n"; body += "User: "******"\n"; body += "First Name: " + objNewUser.FirstName + "\n"; body += "Last Name: " + objNewUser.LastName + "\n"; body += "Email: " + objNewUser.Email + "\n"; body += "Portal: " + objNewUser.PortalID + "\n"; body += "User-Agent: " + Request.UserAgent + "\n\n"; // DotNetNuke.Services.Mail.Mail.SendMail("*****@*****.**", "*****@*****.**", "", "NEW aqufit.com USER", body, "", "HTML", "", "", "", ""); Affine.Utils.GmailUtil gmail = new Utils.GmailUtil(); gmail.Send("*****@*****.**", "User Signup: " + objNewUser.Username, body); // where they brought here by a group? long gid = Convert.ToInt64(hiddenGroupKey.Value); if (gid > 0) { // if so then we auto add them to the group. Data.Managers.LINQ.DataManager.Instance.JoinGroup(us.Id, gid, Utils.ConstsUtil.Relationships.GROUP_MEMBER); } // See if this person was invited by anyone. ContactInvite invite = entities.ContactInvites.Include("UserSetting").FirstOrDefault(i => i.Email == us.UserEmail); if (invite != null) { // this person was invited by someone so lets make them friends.... string stat = Affine.Data.Managers.LINQ.DataManager.Instance.AcceptFriendRequests(invite.UserSetting.Id, us.Id); // TODO: assume success send for now } // TODO: look through a list of stored contacts to get a sugested friends list... } else { // registration error string body = "User Registration Form FAILED (Us\n\n"; body += "ID: " + objNewUser.UserID + "\n"; body += "User: "******"\n"; body += "First Name: " + objNewUser.FirstName + "\n"; body += "Last Name: " + objNewUser.LastName + "\n"; body += "Email: " + objNewUser.Email + "\n"; body += "REGISTRATION ERROR: " + userCreateStatus.ToString() + "\n"; // string errStr = userCreateStatus.ToString() + "\n\n" + atiSlimControl.ToString(); // DotNetNuke.Services.Mail.Mail.SendMail("*****@*****.**", "*****@*****.**", "", "FAILED REGISTRATION", lErrorText.Text + errStr, "", "HTML", "", "", "", ""); Affine.Utils.GmailUtil gmail = new Utils.GmailUtil(); gmail.Send("*****@*****.**", "**FAIL** REGISTRATION FORM: " + objNewUser.Username, body); litStatus.Text = "REGISTRATION ERROR: " + userCreateStatus.ToString(); return false; } } return true; }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack && !Page.IsCallback && this.ProfileSettings != null) { atiProfileImage.Settings = ProfileSettings; atiProfileImage.Small = this.IsSmall; urlBase = ResolveUrl("~/"); hlUserStats.HRef = urlBase + ProfileSettings.UserName + "/achievements"; divAddTo.Visible = true; atiProfileLinks.ProfileSettings = this.ProfileSettings; atiProfileLinks.IsOwner = this.IsOwner; atiProfileLinks.IsFriend = this.IsFriend; atiProfileLinks.Mode = this.Mode; atiProfileSuggest.ProfileSettings = this.ProfileSettings; if (this.IsOwner) { bCompareTo.Visible = false; atiProfileImage.IsOwner = true; atiWebLinksList.IsOwner = true; divAddTo.Visible = false; atiFriendsPhotos.FriendListLink = ResolveUrl("~/" + ProfileSettings.UserName + "/Friends"); } else { atiProfileImage.IsOwner = false; atiFriendsPhotos.FriendListLink = "javascript: Aqufit.Windows.WatchList.open();"; aCompareTo.HRef = urlBase + "compare/" + ProfileSettings.UserName; bCompareTo.Visible = ShowCompareButton; } litAchievements.Text = "Achievements"; // TODO: take this out of the control.. ( prolly put it in the pagebase .. have a setup ) aqufitEntities entities = new aqufitEntities(); if (this.Mode == Affine.Utils.ConstsUtil.ProfileMode.NORMAL) { long[] friendIds = null; if (this.MainGroup != null) { litMainGroup.Text = "<a style=\"display: block; padding-top: 10px; font-weight:bold; font-size: 13px;\" href=\"/group/" + this.MainGroup.UserName + "\">" + this.MainGroup.UserName + "</a>"; } else { litMainGroup.Visible = false; } // settup the users web links atiWebLinksList.ProfileSettings = ProfileSettings; if (this.ProfileSettings is Group) { bCompareTo.Visible = false; litMainGroup.Visible = false; divAddTo.Visible = false; hlUserStats.HRef = ResolveUrl("~/") + ProfileSettings.UserName + "/achievements"; lAthleteTerm.Text = "<span>Members</span>"; atiFriendsPhotos.FriendTerm = "Member"; atiFriendsPhotos.FriendTermPlural = "Members"; atiFriendsPhotos.FriendListLink = "javascript: Aqufit.Windows.WatchList.open();"; // TODO: cache this grabbing of the friend ids from the stream service friendIds = entities.UserFriends.Where(f => (f.SrcUserSettingKey == ProfileSettings.Id || f.DestUserSettingKey == ProfileSettings.Id) && (f.Relationship >= (int)Affine.Utils.ConstsUtil.Relationships.GROUP_OWNER)).Select(f => (f.SrcUserSettingKey == this.ProfileSettings.Id ? f.DestUserSettingKey : f.SrcUserSettingKey)).ToArray(); // TODO: we only want the best times / scores ect.. ( Take this out of the control as well ) WODSchedule lastWOD = entities.WODSchedules.Include("WOD").Include("WOD.WODType").Where(w => w.Date.CompareTo(DateTime.Now) < 0).OrderByDescending(w => w.Date).FirstOrDefault(); if (lastWOD != null) { litAchievements.Text = lastWOD.WOD.Name; IQueryable <Workout> crossfitWorkouts = entities.UserStreamSet.Include("UserSetting").Include("WOD").OfType <Workout>().Where(w => w.WOD.Id == lastWOD.WOD.Id); int numDistinct = crossfitWorkouts.Count(); const int MAX_DISPLAY = 15; IQueryable <Workout> wodsToDisplay = null; if (numDistinct > MAX_DISPLAY) { Random rand = new Random((int)DateTime.Now.Millisecond); int skip = rand.Next(numDistinct - MAX_DISPLAY); wodsToDisplay = crossfitWorkouts.OrderByDescending(w => w.Id).Skip(skip).Take(MAX_DISPLAY); } else { wodsToDisplay = crossfitWorkouts.OrderByDescending(w => w.Id).Take(MAX_DISPLAY); } Workout[] workoutArray = wodsToDisplay.ToArray(); IList <DesktopModules_ATI_Base_controls_ATI_NameValueGrid.TotalItem> cfTotals = new List <DesktopModules_ATI_Base_controls_ATI_NameValueGrid.TotalItem>(); // links are like "workout/187" string baseUrl = ResolveUrl("~"); if (lastWOD.WOD.WODType.Id == (int)Affine.Utils.WorkoutUtil.WodType.TIMED) { cfTotals = workoutArray.Select(w => new DesktopModules_ATI_Base_controls_ATI_NameValueGrid.TotalItem() { Name = w.UserSetting.UserName, Total = Affine.Utils.UnitsUtil.durationToTimeString(Convert.ToInt64(w.Duration)), Link = baseUrl + w.UserSetting.UserName }).ToList(); } else if (lastWOD.WOD.WODType.Id == (int)Affine.Utils.WorkoutUtil.WodType.SCORE || lastWOD.WOD.WODType.Id == (int)Affine.Utils.WorkoutUtil.WodType.AMRAP) { cfTotals = workoutArray.Select(w => new DesktopModules_ATI_Base_controls_ATI_NameValueGrid.TotalItem() { Name = w.UserSetting.UserName, Total = Convert.ToString(w.Score), Link = baseUrl + w.UserSetting.UserName }).ToList(); } else if (lastWOD.WOD.WODType.Id == (int)Affine.Utils.WorkoutUtil.WodType.MAX_WEIGHT) { cfTotals = workoutArray.Select(w => new DesktopModules_ATI_Base_controls_ATI_NameValueGrid.TotalItem() { Name = w.UserSetting.UserName, Total = "" + Affine.Utils.UnitsUtil.systemDefaultToUnits(w.Max.Value, Affine.Utils.UnitsUtil.MeasureUnit.UNIT_LBS), Link = baseUrl + w.UserSetting.UserName }).ToList(); } // TODO: we need the link (?? are we going to goto stats page.. or to the workout stream view) nvgCrossfit.Totals = cfTotals; } } else { string baseUrl = ResolveUrl("~") + "workout/"; // TODO: cache this grabbing of the friend ids from the stream service friendIds = entities.UserFriends.Where(f => (f.SrcUserSettingKey == ProfileSettings.Id || f.DestUserSettingKey == ProfileSettings.Id) && (f.Relationship == (int)Affine.Utils.ConstsUtil.Relationships.FRIEND)).Select(f => (f.SrcUserSettingKey == this.ProfileSettings.Id ? f.DestUserSettingKey : f.SrcUserSettingKey)).ToArray(); lAthleteTerm.Text = "<span>Athletes</span>"; // TODO: we only want the best times / scores ect.. ( Take this out of the control as well ) IQueryable <Workout> crossfitWorkouts = entities.UserStreamSet.OfType <Workout>().Include("WOD").Where(w => w.UserSetting.Id == ProfileSettings.Id && w.WorkoutTypeKey == (int)Affine.Utils.WorkoutUtil.WorkoutType.CROSSFIT && w.IsBest == true); int numDistinct = crossfitWorkouts.Select(w => w.WOD).Count(); const int MAX_DISPLAY = 10; IQueryable <Workout> wodsToDisplay = null; if (numDistinct > MAX_DISPLAY) { Random rand = new Random((int)DateTime.Now.Millisecond); int skip = rand.Next(numDistinct - MAX_DISPLAY); wodsToDisplay = crossfitWorkouts.OrderByDescending(w => w.Id).Skip(skip).Take(MAX_DISPLAY); } else { wodsToDisplay = crossfitWorkouts.OrderByDescending(w => w.Id).Take(MAX_DISPLAY); } // We need to split up into WOD types now... Workout[] timedWods = wodsToDisplay.Where(w => w.WOD.WODType.Id == (int)Affine.Utils.WorkoutUtil.WodType.TIMED).ToArray(); IList <DesktopModules_ATI_Base_controls_ATI_NameValueGrid.TotalItem> cfTotals = timedWods.Select(w => new DesktopModules_ATI_Base_controls_ATI_NameValueGrid.TotalItem() { Name = w.Title, Total = Affine.Utils.UnitsUtil.durationToTimeString(Convert.ToInt64(w.Duration)), Link = baseUrl + w.WOD.Id }).ToList(); // Now all the scored ones... Workout[] scoredWods = wodsToDisplay.Where(w => w.WOD.WODType.Id == (int)Affine.Utils.WorkoutUtil.WodType.SCORE).ToArray(); cfTotals = cfTotals.Concat(scoredWods.Select(w => new DesktopModules_ATI_Base_controls_ATI_NameValueGrid.TotalItem() { Name = w.Title, Total = Convert.ToString(w.Score), Link = baseUrl + w.WOD.Id }).ToList()).ToList(); // Now all the max ones... Workout[] maxWods = wodsToDisplay.Where(w => w.WOD.WODType.Id == (int)Affine.Utils.WorkoutUtil.WodType.MAX_WEIGHT).ToArray(); cfTotals = cfTotals.Concat(maxWods.Select(w => new DesktopModules_ATI_Base_controls_ATI_NameValueGrid.TotalItem() { Name = w.Title, Total = Affine.Utils.UnitsUtil.systemDefaultToUnits(w.Max.Value, Affine.Utils.UnitsUtil.MeasureUnit.UNIT_LBS) + " " + Affine.Utils.UnitsUtil.unitToStringName(Affine.Utils.UnitsUtil.MeasureUnit.UNIT_LBS), Link = baseUrl + w.WOD.Id }).ToList()).ToList(); // TODO: we need the link (?? are we going to goto stats page.. or to the workout stream view) nvgCrossfit.Totals = cfTotals; } IQueryable <Affine.Data.User> friends = entities.UserSettings.OfType <User>().Where(Affine.Utils.Linq.LinqUtils.BuildContainsExpression <User, long>(s => s.Id, friendIds)).OrderBy(s => s.Id); int fcount = friends.Count(); UserSettings[] firendSettings = null; if (fcount > 6) { Random rand = new Random((int)DateTime.Now.Millisecond); int skip = rand.Next(fcount - 6); firendSettings = friends.Skip(skip).Take(6).ToArray(); } else { firendSettings = friends.Take(6).ToArray(); } atiFriendsPhotos.FriendKeyList = firendSettings; atiFriendsPhotos.User = ProfileSettings; atiFriendsPhotos.FriendCount = fcount; // atiSendMessage.UserSettings = firendSettings; } else if (this.Mode == Affine.Utils.ConstsUtil.ProfileMode.BIO) { pAchievements.Visible = false; pWebLinks.Visible = false; pFriends.Visible = false; bCompareTo.Visible = false; if (this.IsOwner) { pAchievements.Visible = false; } pBodyComp.Visible = true; pTrainingHistory.Visible = true; BodyComposition bc = entities.BodyComposition.FirstOrDefault(b => b.UserSetting.Id == ProfileSettings.Id); pBio.Visible = true; litBio.Text = "<p>No Info</p>"; litTrainingHistory.Text = "<p>No Info</p>"; string height = "Unknown"; string weight = "Unknown"; if (bc != null) { litBio.Text = "<p>" + bc.Bio + "</p>"; litTrainingHistory.Text = "<p>" + bc.Description + "</p>"; if (bc.Height.HasValue) { double inches = Affine.Utils.UnitsUtil.systemDefaultToUnits(bc.Height.Value, Affine.Utils.UnitsUtil.MeasureUnit.UNIT_INCHES); double feet = Math.Floor(inches / 12); inches = Math.Floor(inches % 12); height = feet + " feet " + inches + " inches"; } if (bc.Weight.HasValue) { double lbs = Affine.Utils.UnitsUtil.systemDefaultToUnits(bc.Weight.Value, Affine.Utils.UnitsUtil.MeasureUnit.UNIT_LBS); weight = lbs + " " + Affine.Utils.UnitsUtil.unitToStringName(Affine.Utils.UnitsUtil.MeasureUnit.UNIT_LBS); } } IList <DesktopModules_ATI_Base_controls_ATI_NameValueGrid.TotalItem> cfHeightWeight = new List <DesktopModules_ATI_Base_controls_ATI_NameValueGrid.TotalItem>(); cfHeightWeight.Add(new DesktopModules_ATI_Base_controls_ATI_NameValueGrid.TotalItem() { Name = "Height", Total = height }); cfHeightWeight.Add(new DesktopModules_ATI_Base_controls_ATI_NameValueGrid.TotalItem() { Name = "Weight", Total = weight }); nvgBodyComp.Totals = cfHeightWeight; } if (this.IsFriend) // You are viewing a friends profile... so should the "Send Message Button"; { divAddTo.Visible = false; } else { if (this.IsFollowing) { // We need to change the "following link" to a smaller "Send Friend Request" bAddTo.Visible = false; hlSendFriendRequest.Visible = true; } } } }
public BodyMassIndexClassification(BodyCompositionClassificationParameters parameters) { _patient = parameters.Patient ?? throw new ArgumentNullException(nameof(parameters.Patient)); _bodyComposition = parameters.BodyComposition ?? throw new ArgumentNullException(nameof(parameters.BodyComposition)); }
// Register the type on the generic ThingBaseToFhir partial class public static Observation ToFhir(this BodyComposition bodyComposition) { return(BodyCompositionToFhir.ToFhirInternal(bodyComposition, ToFhirInternal <Observation>(bodyComposition))); }