コード例 #1
0
 public static void DeleteChild(int id)
 {
     try
     {
         using (DAL.TafToTafEntities2 db = new DAL.TafToTafEntities2())
         {
             var child = db.Children.FirstOrDefault(ch => ch.Id == id);
             if (child != null)
             {
                 db.Children.Remove(child);
             }
             var childInKGarden = db.ChildKinderGardens.First(ch => ch.ChildID == id);
             db.ChildKinderGardens.Remove(childInKGarden);
             var parent = db.Users.FirstOrDefault(u => u.Password == child.Tz);
             if (parent != null)
             {
                 db.Users.Remove(parent);
             }
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
コード例 #2
0
 public static ChildDto SelectChildByParentId(int parentId)
 {
     using (DAL.TafToTafEntities2 db = new DAL.TafToTafEntities2())
     {
         var child = db.Children.FirstOrDefault(ch => ch.ParentID == parentId);
         if (child == null)
         {
             return(null);
         }
         return(Converters.ChildC.ToChildDTO(child));
     }
 }
コード例 #3
0
        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);
        }
コード例 #4
0
 public static void EditChild(int id, ChildDto child)
 {
     using (DAL.TafToTafEntities2 db = new DAL.TafToTafEntities2())
     {
         var editChild = db.Children.FirstOrDefault(ch => ch.Id == id);
         if (editChild != null)
         {
             editChild.FirstName       = child.FirstName;
             editChild.LastName        = child.LastName;
             editChild.Tz              = child.Tz;
             editChild.BornDate        = child.BornDate;
             editChild.NumHoursConfirm = child.NumHoursConfirm;
             editChild.ParentID        = child.ParentID;
         }
         db.SaveChanges();
     }
 }
コード例 #5
0
 public static List <CalenderDto> SelectCalenderChild(int childId)//מקבלת קוד ילד ומחזירה את כל הטיפולים שלן
 {
     using (TafToTafEntities2 db = new DAL.TafToTafEntities2())
     {
         var child = db.Children.FirstOrDefault(ch => ch.Id == childId);
         if (child == null)
         {
             return(null);
         }
         List <CalenderDto> CalenderList = new List <CalenderDto>();
         var Treatments = db.Calanders.Where(tret => tret.KindId < 4 && tret.DateStart.Value.Year == year && tret.ChildId == childId).ToList();
         foreach (var calender in Treatments)
         {
             CalenderList.Add(CalanderC.ToCalanderDto(calender));
         }
         return(CalenderList);
     }
 }
コード例 #6
0
 public static List <CalenderDto> SelectChildParentMeeting(int childId)//מפגשי הורים לילד
 {
     using (DAL.TafToTafEntities2 db = new DAL.TafToTafEntities2())
     {
         var child = db.Children.FirstOrDefault(ch => ch.Id == childId);
         if (child == null)
         {
             return(null);
         }
         List <CalenderDto> CalenderList = new List <CalenderDto>();
         var childknd   = db.ChildKinderGardens.FirstOrDefault(knd => knd.ChildID == childId);
         var meetParent = db.Calanders.Where(meet => meet.KindId == 5 && meet.DateStart.Value.Year == year && meet.KinderGardenId == childknd.KindrGardenID && meet.ChildId == child.Id).ToList();
         foreach (var calender in meetParent)
         {
             CalenderList.Add(CalanderC.ToCalanderDto(calender));
         }
         return(CalenderList);
     }
 }
コード例 #7
0
 public static List <CalenderDto> SelectWorkerTeamMeeting(int workerId)//מפגשי צוות לעובדת
 {
     using (DAL.TafToTafEntities2 db = new DAL.TafToTafEntities2())
     {
         List <KinderGardenDto> listKnd      = KinderGardenLogic.SelectWorkersKinderGardens(workerId);
         List <CalenderDto>     CalenderList = new List <CalenderDto>();
         List <DAL.Calander>    Meetings     = new List <DAL.Calander>();
         foreach (var knd in listKnd)
         {
             Meetings.AddRange(db.Calanders.Where(meet => meet.KindId == 4 && meet.DateStart.Value.Year == year &&
                                                  DateTime.Now.Month - meet.DateStart.Value.Month <= 2 && meet.KinderGardenId == knd.Id).ToList());
         }
         foreach (var calender in Meetings)
         {
             CalenderList.Add(CalanderC.ToCalanderDto(calender));
         }
         return(CalenderList);
     }
 }
コード例 #8
0
        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);
        }
コード例 #9
0
 public static List <CalenderDto> SelectCalenderWorker(int workerId)//מקבלת קוד עובדת ומחזירה את כל הטיפולים שלה ואת הישיבות צוות והורים
 {
     using (DAL.TafToTafEntities2 db = new DAL.TafToTafEntities2())
     {
         var worker = db.Professionals.FirstOrDefault(p => p.Id == workerId);
         if (worker == null)
         {
             return(null);
         }
         List <CalenderDto> CalenderList = new List <CalenderDto>();
         var Treatments = db.Calanders.Where(tret => tret.KindId < 4 && tret.DateStart.Value.Year == year && tret.ProfessionalId == workerId).ToList();
         CalenderList.AddRange(SelectWorkerTeamMeeting(workerId));
         CalenderList.AddRange(SelectWorkerParentsMeeting(workerId));
         foreach (var calender in Treatments)
         {
             CalenderList.Add(CalanderC.ToCalanderDto(calender));
         }
         return(CalenderList);
     }
 }
コード例 #10
0
 public static void InsertChild(DTO.ChildPost child, string kGardenName)
 {
     using (DAL.TafToTafEntities2 db = new DAL.TafToTafEntities2())
     {
         int  kGardenID = db.KinderGardens.First(kg => kg.Name == kGardenName).Id;
         User user      = new User()
         {
             LastName  = child.LastName,
             FirstName = child.ParentName,
             KindUser  = 3,
             UserName  = "******" + "3",
             Email     = child.ParentEmail,
             Password  = child.Tz,
         };
         db.Users.Add(user);
         db.SaveChanges();
         ChildDto childDto = new ChildDto()
         {
             FirstName       = child.FirstName,
             LastName        = child.LastName,
             BornDate        = child.BornDate,
             NumHoursConfirm = child.NumHoursConfirm,
             Tz       = child.Tz,
             ParentID = db.Users.First(u => u.Password == child.Tz).Id
         };
         db.Children.Add(ChildC.ToChildDAL(childDto));
         db.ChildKinderGardens.Add(new ChildKinderGarden()
         {
             ChildID       = child.Id,
             KindrGardenID = kGardenID,
             BeginYear     = PublicLogic.CalcBeaginYear(),
             EndYear       = PublicLogic.CalcEndYear(),
         });
         db.SaveChanges();
         PublicLogic.SendEmail("TLT3", child.Tz, child.ParentEmail);
     }
 }