public static List <ChildDto> SelectChildren() { List <ChildDto> childrenList = new List <ChildDto>(); using (DAL.TafToTafEntities2 db = new DAL.TafToTafEntities2()) { var children = db.Children.OrderBy(c => c.LastName).ToList(); foreach (var child in children) { childrenList.Add(ChildC.ToChildDTO(child)); } } return(childrenList); }
public static List <ChildDto> SelectWorkerChildren(int workerID) { List <int> childrenIDs = new List <int>(); List <ChildDto> childrenList = new List <ChildDto>(); using (DAL.TafToTafEntities2 db = new DAL.TafToTafEntities2()) { var calendersWorker = db.Calanders.Where(c => c.ProfessionalId == workerID && c.DateStart != null && c.DateStart.Value.Year == year).ToList(); foreach (var calendar in calendersWorker) { if (childrenIDs.Contains(calendar.ChildId.GetValueOrDefault()) == false) { childrenIDs.Add(calendar.ChildId.GetValueOrDefault()); childrenList.Add(ChildC.ToChildDTO(db.Children.First(ch => ch.Id == calendar.ChildId))); } } } return(childrenList); }
public static List <ChildDto> GetChildrenInKinderGarden(string kinderGardenName) { List <ChildDto> ChildrenDTO = new List <ChildDto>(); using (TafToTafEntities2 db = new TafToTafEntities2()) { int kinderGardenId = db.KinderGardens.First(kg => kg.Name == kinderGardenName).Id; foreach (var childKinderGarden in db.ChildKinderGardens) { if (childKinderGarden.KindrGardenID == kinderGardenId && childKinderGarden.BeginYear.GetValueOrDefault() == PublicLogic.CalcBeaginYear()) { Child childDAL = db.Children.First(ch => ch.Id == childKinderGarden.ChildID); ChildrenDTO.Add(ChildC.ToChildDTO(childDAL)); } } return(ChildrenDTO); } }