private static IOrderedQueryable<PersonalizedContent> GetOrderedChildContent(PersonalizationContext dataContext, Child child) { return from entry in dataContext.PersonalizedContent where entry.ChildId == child.ChildId orderby entry.DisplayOrder select entry; }
public static void RefreshAndSavePersonalizedContent(Member member, Child child) { DateTime now = DateTime.Now; List<UnderstoodDotOrg.Domain.Search.Article> articles = Domain.Search.SearchHelper.GetArticles(member, child, now); PersonalizationHelper.SavePersonalizedContent(member, child, articles); }
protected void btnSubmit_Click(object sender, EventArgs e) { //do stuff if (this.CurrentMember != null) { var child = new UnderstoodDotOrg.Domain.Membership.Child(); //required values that we can default child.EvaluationStatus = new Guid(Constants.ChildEvaluation.StatusEvaluationNo); child.Nickname = TextHelper.RemoveHTML(txtChildNickname.Text); child.Gender = uxBoy.Checked ? "boy" : "girl"; child.Grades.Add(new Grade() { Key = Guid.Parse(ddlGrades.SelectedValue) }); foreach (var item in rptIssues.Items) { var checkbox = item.FindControl("uxIssueCheckbox") as CheckBox; var hidden = item.FindControl("uxIssueHidden") as HiddenField; if (checkbox.Checked) { //singleChild.Issues.Add(new Issue() { Key = Guid.Parse(checkbox.Attributes["value"]) }); child.Issues.Add(new Issue() { Key = Guid.Parse(hidden.Value) }); } } MembershipManager membershipManager = new MembershipManager(); child = membershipManager.AddChild(child, this.CurrentMember.MemberId); PersonalizationHelper.RefreshAndSavePersonalizedContent(child.ChildId); //should we update the current member? } this.ReturnRedirect(); //oh, you're still here... Response.Redirect(MyAccountItem.GetMyAccountPage().GetUrl()); }
public static List<DefaultArticlePageItem> GetChildPersonalizedContents(Child child) { List<DefaultArticlePageItem> results = new List<DefaultArticlePageItem>(); using (var pc = new PersonalizationContext(System.Configuration.ConfigurationManager.ConnectionStrings[Constants.ConnectionStringMembership].ConnectionString)) { var guids = from c in GetOrderedChildContent(pc, child) where c.ContentId != Constants.ContentItem.PersonalizedContentNotFound select c.ContentId; foreach (Guid g in guids) { var item = Sitecore.Context.Database.GetItem(Sitecore.Data.ID.Parse(g)); if (item != null) { results.Add(new DefaultArticlePageItem(item)); } } } return results; }
protected void NextButton_Click(object sender, EventArgs e) { var child = new Child(); if ((uxBoy1.Checked || uxGirl1.Checked) && uxSelectGrade1.SelectedValue != string.Empty) { child.Grades.Add(new Grade() { Key = Constants.GradesByValue[uxSelectGrade1.SelectedValue] }); child.Gender = uxBoy1.Checked ? "boy" : "girl"; //CurrentMember.Children.Add(child); } var issues = new List<Issue>(); if (q1a1.Checked) { issues.Add(new Issue() { Key = Constants.Issues.ElementAt(0).Key, Value = Constants.Issues.ElementAt(0).Value }); } if (q1a2.Checked) { issues.Add(new Issue() { Key = Constants.Issues.ElementAt(1).Key, Value = Constants.Issues.ElementAt(1).Value }); } if (q1a3.Checked) { issues.Add(new Issue() { Key = Constants.Issues.ElementAt(2).Key, Value = Constants.Issues.ElementAt(2).Value }); } if (q1a4.Checked) { issues.Add(new Issue() { Key = Constants.Issues.ElementAt(3).Key, Value = Constants.Issues.ElementAt(3).Value }); } if (q1a5.Checked) { issues.Add(new Issue() { Key = Constants.Issues.ElementAt(4).Key, Value = Constants.Issues.ElementAt(4).Value }); } if (q1a6.Checked) { issues.Add(new Issue() { Key = Constants.Issues.ElementAt(5).Key, Value = Constants.Issues.ElementAt(5).Value }); } if (q1a7.Checked) { issues.Add(new Issue() { Key = Constants.Issues.ElementAt(6).Key, Value = Constants.Issues.ElementAt(6).Value }); } if (q1a8.Checked) { issues.Add(new Issue() { Key = Constants.Issues.ElementAt(7).Key, Value = Constants.Issues.ElementAt(7).Value }); } if (q1a9.Checked) { issues.Add(new Issue() { Key = Constants.Issues.ElementAt(8).Key, Value = Constants.Issues.ElementAt(8).Value }); } if (q1a10.Checked) { issues.Add(new Issue() { Key = Constants.Issues.ElementAt(9).Key, Value = Constants.Issues.ElementAt(9).Value }); } child.Issues = issues; child.Nickname = ScreenNameTextBox.Text; // handle redirects if (!q2a1.Checked) // Has (child) been formally evauluated for ... { //BG: Set alternative child evaulation status if (q2a2.Checked)//BG: Child has not been evaluated { child.EvaluationStatus = new Guid(Constants.ChildEvaluation.StatusEvaluationNo); } else if (q2a3.Checked)//BG: Child evaluation is in progress { child.EvaluationStatus = new Guid(Constants.ChildEvaluation.StatusEvaluationInProgress); } } else { child.EvaluationStatus = new Guid(Constants.ChildEvaluation.StatusEvaluationYes); if (uxIEPStatus.SelectedValue != string.Empty) { child.IEPStatus = Guid.Parse(uxIEPStatus.SelectedValue); } if (ux504Status.SelectedValue != string.Empty) { child.Section504Status = Guid.Parse(ux504Status.SelectedValue); } foreach (var item in uxLeftList.Items) { var check = item.FindControl("diagnosis") as CheckBox; if (check != null && check.Checked) { child.Diagnoses.Add(new Domain.Membership.Diagnosis() { Key = Guid.Parse(check.Attributes["guid"]) }); } } foreach (var item in uxRightList.Items) { var check = item.FindControl("diagnosis") as CheckBox; if (check != null && check.Checked) { child.Diagnoses.Add(new Domain.Membership.Diagnosis() { Key = Guid.Parse(check.Attributes["guid"]) }); } } } CurrentMember.Children.Add(child); var membershipManager = new MembershipManager(); membershipManager.UpdateMember(CurrentMember); Response.Redirect(MyProfileItem.GetMyProfilePage().InnerItem.GetUrl()); }
private void UpdateChild(Member member, Child child) { List<UnderstoodDotOrg.Domain.Search.Article> articles = Domain.Search.SearchHelper.GetArticles(member, child, _searchDate); //TEST CODE List<UnderstoodDotOrg.Domain.SitecoreCIG.Poses.Base.BasePageItems.DefaultArticlePageItem> recommendedArticles; recommendedArticles = SearchHelper.GetRecommendedContent(member, UnderstoodDotOrg.Domain.SitecoreCIG.Poses.Base.BasePageItems.DefaultArticlePageItem.TemplateId) .Where(a => a.GetItem() != null) .Select(a => new UnderstoodDotOrg.Domain.SitecoreCIG.Poses.Base.BasePageItems.DefaultArticlePageItem(a.GetItem())) .ToList(); List<UnderstoodDotOrg.Domain.SitecoreCIG.Poses.Pages.CommunityTemplates.Blogs.BlogsPostPageItem> recommendedBlogs; recommendedBlogs = SearchHelper.GetRecommendedContent(member, UnderstoodDotOrg.Domain.SitecoreCIG.Poses.Pages.CommunityTemplates.Blogs.BlogsPostPageItem.TemplateId) .Where(a => a.GetItem() != null) .Select(a => new UnderstoodDotOrg.Domain.SitecoreCIG.Poses.Pages.CommunityTemplates.Blogs.BlogsPostPageItem(a.GetItem())) .ToList(); //List<UnderstoodDotOrg.Domain.SitecoreCIG.Poses.Base.BasePageItems.DefaultArticlePageItem> recommendedContent; //recommendedContent = SearchHelper.GetRecommendedContent(member, UnderstoodDotOrg.Domain.SitecoreCIG.Poses.Base.BasePageItems.DefaultArticlePageItem.TemplateId) // .Where(a => a.GetItem() != null) // .Select(a => new UnderstoodDotOrg.Domain.SitecoreCIG.Poses.Base.BasePageItems.DefaultArticlePageItem(a.GetItem())) // .ToList(); //END TEST CODE PersonalizationHelper.SavePersonalizedContent(member, child, articles); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.Write("Connecting to salesforce"); string fname = context.Request.QueryString["fname"]; string lname = context.Request.QueryString["lname"]; string email = context.Request.QueryString["email"]; SalesforceManager sfMgr = new SalesforceManager("*****@*****.**", "8f9C3Ayq", "hlY0jOIILtogz3sQlLUtmERlu"); if (sfMgr.LoggedIn) { //we are logged into salesforce. Member m = new Member(); m.MemberId = Guid.NewGuid(); //adding in a random guid m.UserId = Guid.NewGuid(); //add in a random user id guid m.allowConnections = true; m.allowNewsletter = false ; m.emailSubscription = true; m.FirstName = fname; m.hasOtherChildren = false; m.isFacebookUser = true; m.isPrivate = true; m.LastName = lname; m.PersonalityType = new Guid("8B7EB70D-64B2-45B9-B06E-6AA5CB6FE983");//Optimisic Parent //m.Phone = 7811112222; //member phone & db need to be updated . int32 is too small for a phone number m.Role = new Guid("2BF9D7BE-2E40-432C-ADE7-A25C80B9B9EE");//Father Random random = new Random(); int randomNumber = random.Next(0, 10000); m.ScreenName = "dummyuser_" + randomNumber.ToString(); m.ZipCode = "01111"; Journey j = new Journey(); j.Key = new Guid( "0642E401-8E66-4C69-89C6-294C257456C8"); j.Value = "Still Figuring it Out"; m.Journeys.Add(j); Interest intr = new Interest(); intr.Key = new Guid("110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9"); intr.Value = "Assisted Living"; m.Interests.Add(intr); Interest intr2 = new Interest(); intr2.Key = new Guid("3C185099-76B4-49DD-80D4-A069A3F55FA1"); intr2.Value = "Homework and Study Skills"; m.Interests.Add(intr2); //setting up a couple of issues for children Issue issueOne = new Issue(); issueOne.Key = new Guid("3390C210-0B22-48FD-A411-881F956EDC0C"); issueOne.Value = "Listening"; Issue issueTwo = new Issue(); issueTwo.Key = new Guid("1D338D37-CF4E-4C1C-9499-EBA6C0A2BBA0"); issueTwo.Value = "Math"; //setting up a couple of diagnosis values for children Diagnosis d1 = new Diagnosis(); d1.Key = new Guid("A66286A0-CD70-4FDD-9D13-9CF1C90EFC4A"); d1.Value = "Receptive Language Disorder"; Diagnosis d2 = new Diagnosis(); d2.Key = new Guid("7A035CC2-D6BD-4332-9518-7AB22083F652"); d2.Value = "ADHD"; //setting up a couple of grade values for children Grade g1 = new Grade(); g1.Key = new Guid("E26222FB-07CD-413B-9127-9050B6D2D037"); g1.Value = "Grade 1"; Grade g2 = new Grade(); g2.Key = new Guid("E0B459C0-548A-4E6C-854A-E8F475416F12"); g2.Value = "Grade 10"; //setting up status values for children Guid iepStatus = new Guid("FBE464C6-0E52-45C5-A1E9-660CB3C6B688");//yes Guid section504Status = new Guid("55F38A58-7506-454E-95E5-0ECE22A3B99C");//in progress Guid evaluationStatus = new Guid("990FB117-F12E-4E3C-898B-8A9EB217FCFD");//yes //------------------------------------------ //test child 1 //------------------------------------------ Child childOne = new Child(); childOne.ChildId = Guid.NewGuid();//random new child guid for testing purposes childOne.Gender = "boy"; childOne.Nickname = "Bobby"; childOne.IEPStatus = iepStatus; childOne.Section504Status = section504Status; childOne.EvaluationStatus = evaluationStatus; childOne.Issues.Add(issueOne); childOne.Issues.Add(issueTwo); childOne.Grades.Add(g1); childOne.Diagnoses.Add(d1); childOne.Diagnoses.Add(d2); m.Children.Add(childOne); //------------------------------------------ //test child 2 //------------------------------------------ Child childTwo = new Child(); childTwo.ChildId = Guid.NewGuid();//random new guid for testing childTwo.Gender = "boy"; childTwo.Nickname = "Tommy"; childTwo.IEPStatus = iepStatus; childTwo.Section504Status = section504Status; childTwo.EvaluationStatus = evaluationStatus; childTwo.Grades.Add(g2); childTwo.Issues.Add(issueOne); childTwo.Issues.Add(issueTwo); m.Children.Add(childTwo); try { SalesforceActionResult result = sfMgr.CreateWebsiteMemberAsContact(m,email); if (result.Success == true) { context.Response.Write(Environment.NewLine + "Contact (" + fname + " " + lname + ") is 'saved' to salesforce at: (" + sfMgr.SalesforceURL + ")" + Environment.NewLine + "Message: " + result.Message ); } else { context.Response.Write(Environment.NewLine + "Contact (" + fname + " " + lname + ") is not saved to salesforce at: (" + sfMgr.SalesforceURL + ")" + Environment.NewLine + "Message: " + result.Message ); } } catch (Exception ex) { context.Response.Write(Environment.NewLine + "An error occured during in RunSalesfroceUpsert.ashx.cs " + Environment.NewLine + "Message: " + ex.Message + Environment.NewLine + "Stack Trace: " + ex.StackTrace); } } }
/// <summary> /// Trims HTML and whitespace from Child string fields /// </summary> /// <param name="child"></param> /// <returns></returns> public static Child trimFields(Child child) { child.Nickname = child.Nickname != null ? child.Nickname.Trim() : string.Empty; child.Gender = child.Gender != null ? child.Gender.Trim() : string.Empty; return child; }
/// <summary> /// Private method that maps a potentially Entity-disconnected Child to a known-connected instance /// </summary> /// <param name="child">Potentially disconnected Child</param> /// <returns>Known connected Child</returns> private Child mapChild(Child child) { //var tChild = _db.Children.Where(x => x.ChildId == child.ChildId).FirstOrDefault(); var tChild = this.GetChild(child.ChildId); if (tChild == null) { tChild = new Child(); tChild.ChildId = child.ChildId; } tChild.EvaluationStatus = child.EvaluationStatus; tChild.Gender = child.Gender.RemoveHTML(); //gender is required, boy is now default if nothing is provided if (string.IsNullOrEmpty(tChild.Gender)) { tChild.Gender = "boy"; } tChild.HomeLife = child.HomeLife; tChild.IEPStatus = child.IEPStatus; tChild.Nickname = child.Nickname.RemoveHTML(); //DB field limited to 20 characters, try to use more and this will puke if (tChild.Nickname.Length > 20) { tChild.Nickname = tChild.Nickname.Substring(0, 20); } tChild.Section504Status = child.Section504Status; tChild.Issues.Clear(); tChild.Grades.Clear(); tChild.Diagnoses.Clear(); foreach (var issue in child.Issues) { var i = _db.Issues.Where(x => x.Key == issue.Key).FirstOrDefault(); if (i != null) { tChild.Issues.Add(i); } } foreach (var diagnosis in child.Diagnoses) { var d = _db.Diagnoses.Where(x => x.Key == diagnosis.Key).FirstOrDefault(); if (d != null) { tChild.Diagnoses.Add(d); } } foreach (var grade in child.Grades) { var g = _db.Grades.Where(x => x.Key == grade.Key).FirstOrDefault(); if (g != null) { tChild.Grades.Add(g); } } return tChild; }
protected void btnSubmit_Click(object sender, EventArgs e) { string selectedGrade = ddlGrade.SelectedValue; if (String.IsNullOrEmpty(selectedGrade)) { return; } // TODO: verify if it's ok to clear out unauthenticated user Member member = new Member(); Child child = new Child(); // TODO: replace child name child.Nickname = txtChildName.Text; child.ChildId = Guid.NewGuid(); if (!string.IsNullOrEmpty(hfIssues.Value)) { string[] IDs = hfIssues.Value.Split('|'); foreach (string s in IDs) { ChildIssueItem cii = Sitecore.Context.Database.GetItem(Sitecore.Data.ID.Parse(s)); if (cii != null) { child.Issues.Add(new Issue { Key = Guid.Parse(cii.ID.ToString()), Value = cii.IssueName.Raw }); } } } GradeLevelItem gradeItem = Sitecore.Context.Database.GetItem(Sitecore.Data.ID.Parse(selectedGrade)); if (gradeItem != null) { child.Grades.Add(new Grade { Key = Guid.Parse(selectedGrade), Value = gradeItem.Name.Raw }); } member.Children.Add(child); UnauthenticatedSessionMember = member; // TODO: return unauthenticated users to different results page // Response.Redirect(FormHelper.GetRecommendationUrl()); }
public Child AddChild(Child Child, Guid MemberId) { return this.GetChild(Guid.Empty); }
/// <summary> /// Adds a new child to the membership database /// </summary> /// <param name="Child">Child to add</param> /// <param name="MemberId">Guid of Member that the child should be linked to</param> /// <returns>Child that was added</returns> public Child AddChild(Child Child, Guid MemberId) { try { //using (_db) //{ Child = mapChild(Child); Child.Members.Add(_db.Members.Where(x => x.MemberId == MemberId).First()); _db.Children.Add(Child); _db.SaveChanges(); return Child; //} } catch (DbEntityValidationException ex) { foreach (var eve in ex.EntityValidationErrors) { Debug.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw ex; } }
private static string GetChildPersonalizedArticles(Child child) { StringBuilder sb = new StringBuilder(); XmlWriterSettings settings = new XmlWriterSettings(); settings.Encoding = new UTF8Encoding(false); //settings.OmitXmlDeclaration = true; settings.Indent = false; settings.NewLineHandling = NewLineHandling.None; using (XmlWriter writer = XmlWriter.Create(sb, settings)) { XElement root = new XElement("articles"); var articles = PersonalizationHelper.GetChildPersonalizedContents(child); if (articles.Any()) { var subset = articles.Take(3); foreach (var s in subset) { // TODO: add absolute url root.Add(new XElement("article", new XElement("title", s.ContentPage.PageTitle.Rendered), new XElement("url", s.GetUrl()), new XElement("img", s.GetArticleThumbnailUrl(160, 90)) ) ); } } root.Save(writer); } return sb.ToString(); }
protected void btnSubmit_Click(object sender, EventArgs e) { Member m = new Member(); m.MemberId = Guid.NewGuid(); //adding in a random guid m.UserId = Guid.NewGuid(); //add in a random user id guid m.allowConnections = false; //no community. //------------------- m.allowNewsletter = true; m.emailSubscription = true; // - what are our flags for personalized email m.FirstName = Constants.UnauthenticatedMember_FirstName; m.hasOtherChildren = false; m.isFacebookUser = false; m.isPrivate = true; m.LastName = string.Empty; m.PersonalityType = new Guid("8B7EB70D-64B2-45B9-B06E-6AA5CB6FE983");//Optimisic Parent m.Role = new Guid("2BF9D7BE-2E40-432C-ADE7-A25C80B9B9EE");//Father m.Email = txtEmail.Text; m.Password = Constants.UnauthenticatedMember_Password; Random random = new Random(); int randomNumber = random.Next(0, 10000); m.ScreenName = "dummyuser_" + randomNumber.ToString(); m.ZipCode = "01111"; Journey j = new Journey(); j.Key = new Guid("0642E401-8E66-4C69-89C6-294C257456C8"); j.Value = "Still Figuring it Out"; m.Journeys.Add(j); Interest intr = new Interest(); intr.Key = new Guid("110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9"); intr.Value = "Assisted Living"; m.Interests.Add(intr); Interest intr2 = new Interest(); intr2.Key = new Guid("3C185099-76B4-49DD-80D4-A069A3F55FA1"); intr2.Value = "Homework and Study Skills"; m.Interests.Add(intr2); //setting up a couple of issues for children Issue issueOne = new Issue(); issueOne.Key = new Guid("3390C210-0B22-48FD-A411-881F956EDC0C"); issueOne.Value = "Listening"; Issue issueTwo = new Issue(); issueTwo.Key = new Guid("1D338D37-CF4E-4C1C-9499-EBA6C0A2BBA0"); issueTwo.Value = "Math"; //setting up a couple of diagnosis values for children Diagnosis d1 = new Diagnosis(); d1.Key = new Guid("A66286A0-CD70-4FDD-9D13-9CF1C90EFC4A"); d1.Value = "Receptive Language Disorder"; Diagnosis d2 = new Diagnosis(); d2.Key = new Guid("7A035CC2-D6BD-4332-9518-7AB22083F652"); d2.Value = "ADHD"; //setting up a couple of grade values for children Grade g1 = new Grade(); g1.Key = new Guid("E26222FB-07CD-413B-9127-9050B6D2D037"); g1.Value = "Grade 1"; //setting up status values for children Guid iepStatus = new Guid("FBE464C6-0E52-45C5-A1E9-660CB3C6B688");//yes Guid section504Status = new Guid("55F38A58-7506-454E-95E5-0ECE22A3B99C");//in progress Guid evaluationStatus = new Guid("990FB117-F12E-4E3C-898B-8A9EB217FCFD");//yes //------------------------------------------ //test child 1 -- for the purposes of newsletter we only have 1 child. //------------------------------------------ Child childOne = new Child(); childOne.ChildId = Guid.NewGuid();//random new child guid for testing purposes childOne.Gender = "boy"; childOne.Nickname = "C1"; childOne.IEPStatus = iepStatus; childOne.Section504Status = section504Status; childOne.EvaluationStatus = evaluationStatus; childOne.Issues.Add(issueOne); childOne.Issues.Add(issueTwo); childOne.Grades.Add(g1); childOne.Diagnoses.Add(d1); childOne.Diagnoses.Add(d2); m.Children.Add(childOne); MembershipManager mmgr = new MembershipManager(); Member unauthMember = mmgr.AddUnauthorizedMember(m); //we should now have a "real" unauthorized member with comments and all }
public static void SavePersonalizedContent(Member member, Child child, List<Article> articles) { using (var pc = new PersonalizationContext(System.Configuration.ConfigurationManager.ConnectionStrings[Constants.ConnectionStringMembership].ConnectionString)) { var results = GetOrderedChildContent(pc, child); if (!results.Any()) { return; } int i = 0; foreach (var r in results) { Article article = articles.ElementAtOrDefault(i); if (article == null) { // Not found id r.ContentId = Constants.ContentItem.PersonalizedContentNotFound; } else { r.ContentId = Guid.Parse(article.ItemId.ToString()); } r.DateModified = DateTime.Now; i++; } try { pc.SubmitChanges(); } catch (Exception ex) { Sitecore.Diagnostics.Log.Error( String.Format("Error saving personalization to database for child", child.ChildId.ToString()), ex); } } }
/// <summary> /// Returns Child by Child Guid /// </summary> /// <param name="ChildId">Guid of child to return</param> /// <returns>Child that was requested</returns> public Child GetChild(Guid ChildId) { Child child = new Child(); //using (_db) //{ child = _db.Children .Where(c => c.ChildId == ChildId) .Include(c => c.Diagnoses) .Include(c => c.Issues) .Include(c => c.Members) .Include(c => c.Members.Select(m => m.Interests)) .Include(c => c.Members.Select(m => m.Journeys)) .Include(c => c.Grades) .FirstOrDefault(); //} if (child != null) { child = trimFields(child); } return child; }
public Child GetChild(Guid ChildId) { var child = new Child() { Nickname = "Bobby", IEPStatus = Guid.Parse("{73842143-B6CA-4B6A-A94F-BA59C475A6D7}"), Section504Status = Guid.Parse("{82102C70-B526-47FB-BD99-5F71A33C3C87}"), EvaluationStatus = Guid.Parse("{F6849A63-C841-4D79-BF53-AA68DA6D6EEB}"), HomeLife = Guid.Parse("{8FFA90D9-F2DA-402D-9AC4-7C203769C810}"), Gender = "boy", Issues = new List<Issue>() { new Issue() { Key = Guid.Parse("{FFB5F34E-5A5F-43C6-A987-9AFF713C66C9}"), Value = "Attention or Staying Focused", } }, Diagnoses = new List<Diagnosis>() { new Diagnosis() { Key = Guid.Parse("{7A035CC2-D6BD-4332-9518-7AB22083F652}"), Value = "ADHD", } }, Grades = new List<Grade>() { new Grade() { Key = Guid.Parse("{67AA2A29-E6FF-49B2-9F9E-D29F07C19C23}"), Value = "Grade 3", } }, }; return child; }
/// <summary> /// Updates information about an existing child /// </summary> /// <param name="Child">Child to update</param> /// <returns>Child that was updated</returns> public Child UpdateChild(Child Child) { try { Child = this.mapChild(Child); _db.SaveChanges(); return Child; } catch (DbEntityValidationException ex) { foreach (var eve in ex.EntityValidationErrors) { Debug.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw ex; } }
public Child UpdateChild(Child Child) { return this.GetChild(Guid.Empty); }
protected void NextButton_Click(object sender, EventArgs e) { if ((uxBoy1.Checked || uxGirl1.Checked) && uxSelectGrade1.SelectedValue != string.Empty) { var child = new Child(); child.Grades.Add(new Grade() { Key = Guid.Parse(uxSelectGrade1.SelectedValue) }); child.Gender = uxBoy1.Checked ? "boy" : "girl"; registeringUser.Children.Add(child); } if ((uxBoy2.Checked || uxGirl2.Checked) && uxSelectGrade2.SelectedValue != string.Empty) { var child = new Child(); child.Grades.Add(new Grade() { Key = Guid.Parse(uxSelectGrade2.SelectedValue) }); child.Gender = uxBoy2.Checked ? "boy" : "girl"; registeringUser.Children.Add(child); } if ((uxBoy3.Checked || uxGirl3.Checked) && uxSelectGrade3.SelectedValue != string.Empty) { var child = new Child(); child.Grades.Add(new Grade() { Key = Guid.Parse(uxSelectGrade3.SelectedValue) }); child.Gender = uxBoy3.Checked ? "boy" : "girl"; registeringUser.Children.Add(child); } if ((uxBoy4.Checked || uxGirl4.Checked) && uxSelectGrade4.SelectedValue != string.Empty) { var child = new Child(); child.Grades.Add(new Grade() { Key = Guid.Parse(uxSelectGrade4.SelectedValue) }); child.Gender = uxBoy4.Checked ? "boy" : "girl"; registeringUser.Children.Add(child); } if ((uxBoy5.Checked || uxGirl5.Checked) && uxSelectGrade5.SelectedValue != string.Empty) { var child = new Child(); child.Grades.Add(new Grade() { Key = Guid.Parse(uxSelectGrade5.SelectedValue) }); child.Gender = uxBoy5.Checked ? "boy" : "girl"; registeringUser.Children.Add(child); } if ((uxBoy6.Checked || uxGirl6.Checked) && uxSelectGrade6.SelectedValue != string.Empty) { var child = new Child(); child.Grades.Add(new Grade() { Key = Guid.Parse(uxSelectGrade6.SelectedValue) }); child.Gender = uxBoy6.Checked ? "boy" : "girl"; registeringUser.Children.Add(child); } if (registeringUser.Children.Count > 0) { // get info for each child Response.Redirect(MembershipHelper.GetNextStepURL(2)); } else { // hey, you said you didn't have any children... Response.Redirect(MembershipHelper.GetNextStepURL(4)); } }