public List <ChildCard> GetChildCards() { DateTime today = DateTime.Now; string dayOfWeek = DateTime.Now.DayOfWeek.ToString(); List <Toddler> toddlers = db.Toddlers.Include(t => t.Person).Where(t => t.Person.Active == true).ToList(); List <ChildCard> ccList = new List <ChildCard>(); if (toddlers != null) { foreach (Toddler t in toddlers) { Toddler tod = t; if (tod != null) { ChildCard cc = new ChildCard(); cc.Id = tod.ToddlerId.ToString(); cc.Name = tod.Person.FirstName; cc.Photo = tod.Person.Photo; cc.Status = (ChildStatus)getDiaryToddlerStatus(tod).Status; ccList.Add(cc); } } } return(ccList); }
// return ChildCard for each child that has to come today public List <ChildCard> GetChildCardsForToday() { DateTime today = DateTime.Now; DateTime todaydate = DateTime.Now.Date; string dayOfWeek = DateTime.Now.DayOfWeek.ToString(); List <AgreedDays> agreedDaysList = whoHasToComeToday(dayOfWeek, today); List <ChildCard> ccList = new List <ChildCard>(); if (agreedDaysList != null) { foreach (AgreedDays AD in agreedDaysList) { Toddler tod = getToddler(AD.ToddlerId); if (tod != null) { ChildCard cc = new ChildCard(); cc.Id = tod.ToddlerId.ToString(); cc.Name = tod.Person.FirstName; cc.Photo = tod.Person.Photo; cc.Status = (ChildStatus)getDiaryToddlerStatus(tod).Status; ccList.Add(cc); // Creating RegisteredDay with checkedIn == false RegisteredDay rd = db.RegisteredDays.Where(rdc => (rdc.ToddlerId == tod.ToddlerId) && (rdc.DayInDaycare == todaydate)).FirstOrDefault(); if (rd == null || rd.RegisteredDayId == 0) { rd = new RegisteredDay(); rd.DayInDaycare = todaydate; rd.CheckedIn = false; rd.DaycareIsClosed = false; rd.ExtraDay = false; rd.Toddler = tod; db.RegisteredDays.Add(rd); db.SaveChanges(); } } } } List <RegisteredDay> extraDays = db.RegisteredDays.Include(erd => erd.Toddler).Include(erd => erd.Toddler.Person).Where(erd => (erd.ExtraDay == true) && (erd.DayInDaycare == todaydate)).ToList(); if (extraDays != null) { foreach (RegisteredDay rd in extraDays) { ChildCard cc = new ChildCard(); cc.Id = rd.ToddlerId.ToString(); cc.Name = rd.Toddler.Person.FirstName; cc.Photo = rd.Toddler.Person.Photo; cc.Status = (ChildStatus)getDiaryToddlerStatus(rd.Toddler).Status; ccList.Add(cc); } } return(ccList); }
private void AddingNewCard(params string[] args) { _executorCommands.AddEvent = AddEventHandler; var newChildCard = new ChildCard() { Id = 1, FullName = args[0], DateBirth = args[1], PlaceBirth = args[2], Address = args[3], NumberAccount = args[4], FullNameParents = args[5], HomePhoneNumber = args[6], CellPhoneNumber = args[7], Mail = args[8], Notes = args[9] }; var command = new AddCommand <ChildCard>(_executorCommands, newChildCard); command.Execute(); }
private void B_Click() { switch (GlobalTool.ButtonNameZajiao) { case "ButtonSearch": { List <MyFlower> ParentL = new List <MyFlower>(); List <MyFlower> ParentR = new List <MyFlower>(); if (GlobalTool.BoolColorL == true) { //按颜色L if (GlobalTool.IndexColorL == 0) { GlobalTool.OpenDialogButton(this, "没有选择颜色"); return; } foreach (var everyflower in SelectedColorDicL) { ParentL.Add(everyflower); } } if (GlobalTool.BoolColorR == true) { //按颜色R if (GlobalTool.IndexColorR == 0) { GlobalTool.OpenDialogButton(this, "没有选择颜色"); return; } foreach (var everyflower in SelectedColorDicR) { ParentR.Add(everyflower); } } if (GlobalTool.BoolGeneL == true) { //按基因型L Gene a1 = (Gene)Enum.Parse(typeof(Gene), GlobalTool.ItemA1L); Gene a2 = (Gene)Enum.Parse(typeof(Gene), GlobalTool.ItemA2L); Gene a3 = (Gene)Enum.Parse(typeof(Gene), GlobalTool.ItemA3L); Gene a4 = (Gene)Enum.Parse(typeof(Gene), GlobalTool.ItemA4L); MyFlower f = new MyFlower(SelectedFlower, a1, a2, a3, a4); foreach (var i in f.GetIntArray()) { if (i == 0) { GlobalTool.OpenDialogButton(this, "没有选择基因型"); return; } } foreach (var a in ListColorDic) { if (f.GetGeneName() == a.GetGeneName()) { ParentL.Add(a); } } } if (GlobalTool.BoolGeneR == true) { //按基因型R Gene a1 = (Gene)Enum.Parse(typeof(Gene), GlobalTool.ItemA1R); Gene a2 = (Gene)Enum.Parse(typeof(Gene), GlobalTool.ItemA2R); Gene a3 = (Gene)Enum.Parse(typeof(Gene), GlobalTool.ItemA3R); Gene a4 = (Gene)Enum.Parse(typeof(Gene), GlobalTool.ItemA4R); MyFlower f = new MyFlower(SelectedFlower, a1, a2, a3, a4); foreach (var i in f.GetIntArray()) { if (i == 0) { GlobalTool.OpenDialogButton(this, "没有选择基因型"); return; } } foreach (var a in ListColorDic) { if (f.GetGeneName() == a.GetGeneName()) { ParentR.Add(a); } } } if (GlobalTool.BoolSeedL == true) { //按种子L int index = GlobalTool.IndexSeedL; if (index == 0) { GlobalTool.OpenDialogButton(this, "没有选择种子"); return; } ParentL.Add(ListSeed[index - 1]); } if (GlobalTool.BoolSeedR == true) { //按种子L int index = GlobalTool.IndexSeedR; if (index == 0) { GlobalTool.OpenDialogButton(this, "没有选择种子"); return; } ParentR.Add(ListSeed[index - 1]); } ObservableCollection <ChildCard> result = new ObservableCollection <ChildCard>(); foreach (var L in ParentL) { foreach (var R in ParentR) { var children = FlowerHelper.GetOurChildren(L, R); foreach (var child in children) { var childcard = new ChildCard(L, R, child, FlowerHelper.GetProbability(L, R, child)); bool isinList = false; foreach (var a in result) { if ( ( childcard.Gene == a.Gene && childcard.GeneP1 == a.GeneP1 && childcard.GeneP2 == a.GeneP2 ) || ( childcard.Gene == a.Gene && childcard.GeneP2 == a.GeneP1 && childcard.GeneP1 == a.GeneP2 ) ) { isinList = true; } } if (!isinList) { result.Add(childcard); } } } } Action <IEnumerable> updateAction = new Action <IEnumerable>(ShowData); this.Dispatcher.BeginInvoke(updateAction, result); } break; } }
public static ChildCardDTO EntityToDTO(ChildCard childCard) { var mapper = mapperConfiguration.CreateMapper(); return(mapper.Map <ChildCardDTO>(childCard)); }
private async void Button_Click(object sender, RoutedEventArgs e) { if (GlobalTool.NaviViewMain.SelectedItem != GlobalTool.NaviItemZajiao) { return; } List <MyFlower> ParentL = new List <MyFlower>(); List <MyFlower> ParentR = new List <MyFlower>(); if (GlobalTool.BoolColorL == true) {//按颜色L if (GlobalTool.IndexColorL == 0) { GlobalTool.TipSearch.IsOpen = true; return; } foreach (var everyflower in SelectedColorDicL) { ParentL.Add(everyflower); } } if (GlobalTool.BoolColorR == true) {//按颜色R if (GlobalTool.IndexColorR == 0) { GlobalTool.TipSearch.IsOpen = true; return; } foreach (var everyflower in SelectedColorDicR) { ParentR.Add(everyflower); } } if (GlobalTool.BoolGeneL == true) {//按基因型L Gene a1 = (Gene)Enum.Parse(typeof(Gene), GlobalTool.ItemA1L); Gene a2 = (Gene)Enum.Parse(typeof(Gene), GlobalTool.ItemA2L); Gene a3 = (Gene)Enum.Parse(typeof(Gene), GlobalTool.ItemA3L); Gene a4 = (Gene)Enum.Parse(typeof(Gene), GlobalTool.ItemA4L); MyFlower f = new MyFlower(GlobalTool.SelectedFlower, a1, a2, a3, a4); foreach (var i in f.GetIntArray()) { if (i == 0) { GlobalTool.TipSearch.IsOpen = true; return; } } foreach (var a in GlobalTool.ListColorDic) { if (f.GetGeneName() == a.GetGeneName()) { ParentL.Add(a); } } } if (GlobalTool.BoolGeneR == true) {//按基因型R Gene a1 = (Gene)Enum.Parse(typeof(Gene), GlobalTool.ItemA1R); Gene a2 = (Gene)Enum.Parse(typeof(Gene), GlobalTool.ItemA2R); Gene a3 = (Gene)Enum.Parse(typeof(Gene), GlobalTool.ItemA3R); Gene a4 = (Gene)Enum.Parse(typeof(Gene), GlobalTool.ItemA4R); MyFlower f = new MyFlower(GlobalTool.SelectedFlower, a1, a2, a3, a4); foreach (var i in f.GetIntArray()) { if (i == 0) { GlobalTool.TipSearch.IsOpen = true; return; } } foreach (var a in GlobalTool.ListColorDic) { if (f.GetGeneName() == a.GetGeneName()) { ParentR.Add(a); } } } if (GlobalTool.BoolSeedL == true) {//按种子L int index = GlobalTool.IndexSeedL; if (index == 0) { GlobalTool.TipSearch.IsOpen = true; return; } ParentL.Add(ListSeed[index - 1]); } if (GlobalTool.BoolSeedR == true) {//按种子R int index = GlobalTool.IndexSeedR; if (index == 0) { GlobalTool.TipSearch.IsOpen = true; return; } ParentR.Add(ListSeed[index - 1]); } GlobalTool.ShowProgress(); await Task.Factory.StartNew(() => { ObservableCollection <ChildCard> result = new ObservableCollection <ChildCard>(); foreach (var L in ParentL) { foreach (var R in ParentR) { var children = FlowerHelper.GetOurChildren(L, R); foreach (var child in children) { var childcard = new ChildCard(L, R, child, FlowerHelper.GetProbability(L, R, child)); bool isinList = false; foreach (var a in result) { if ( ( childcard.Gene == a.Gene && childcard.GeneP1 == a.GeneP1 && childcard.GeneP2 == a.GeneP2 ) || ( childcard.Gene == a.Gene && childcard.GeneP2 == a.GeneP1 && childcard.GeneP1 == a.GeneP2 ) ) { isinList = true; } } if (!isinList) { result.Add(childcard); } } } } Sync.Post((o) => { GlobalTool.CloseProgress(); var r = o as ObservableCollection <ChildCard>; ListViewChildren.ItemsSource = r; }, result); }); }