// בדיקה אם הילגד הגיע ואם לא לשלו הודעה 
        public static bool ChackIfSendAReminderEmail()
        {
            using (kindergardenEntities db = new kindergardenEntities())
            {
                List<DailyAlerts> dailyAlerts = db.DailyAlerts.ToList();
                Children children = new Children();
                Parent parent = new Parent();
                foreach (var DA in dailyAlerts)
                {
                    // כאן צריך להוסיף עוד בדיקת תקינות האם כבר נשלח הודעה ומתי 
                    DateTime avg = CalculatingTheAverageArrivalOfAchild(DA.ChildId);
                    if (DateTime.Now.TimeOfDay > avg.TimeOfDay && DA.IsComing_ == false && DA.IsMissing_ == false)
                    {
                        List<Message> messages = db.Message.Where(m => m.IDChild == DA.ChildId && m.Date == DateTime.Today).ToList();
                        if (messages.Count() > 0)
                        {
                            DateTime minDate = DateTime.MaxValue;
                            DateTime maxDate = DateTime.MinValue;
                            // לחפש את התאריך תאריך הכי גדול 
                            foreach (var M in messages)
                            {

                                // בדיקה האם הודיעה נשלחה לפני יותר מ15 דק אפ כן נשלח הודעה שוב 
                                if (M.Date.Value.AddMinutes(15).TimeOfDay > DateTime.Now.TimeOfDay)
                                {
 public static Users Getallpropertyd(string id)
 {
     using (kindergardenEntities db = new kindergardenEntities())
     {
         Users pass = UserDal.Getallpropertyd(id);
         return pass;
     }
 }
Пример #3
0
 public static bool Checkifthereislike(string id)
 {
     using (kindergardenEntities db = new kindergardenEntities())
     {
         bool pass = PropertyChildrenDal.Checkifthereislike(id);
         return(pass);
     }
 }
Пример #4
0
 //public static string GetChild(string id)
 //{
 //    using (KindergardenEntities db = new KindergardenEntities())
 //    {
 //        string pass = (from o in db.Connections where o.UserId.Contains(id) select o.ChildId).FirstOrDefault();
 //        return pass;
 //    }
 //}
 public static string GetChild(string id)
 {
     using (kindergardenEntities db = new kindergardenEntities())
     {
         string pass = PropertyChildrenDal.GetChild(id);
         return(pass);
     }
 }
Пример #5
0
 public static List <Dal.Class1> GetAllChildren()
 {
     using (kindergardenEntities db = new kindergardenEntities())
     {
         List <Dal.Class1> Children = PropertyChildrenDal.GetAllChildren();
         return(Children);
     }
 }
Пример #6
0
        // בדיקה אם הילגד הגיע ואם לא לשלו הודעה
        public static bool ChackIfSendAReminderEmail()
        {
            using (kindergardenEntities db = new kindergardenEntities())
            {
                List <DailyAlerts> dailyAlerts = db.DailyAlerts.ToList();
                Children           children    = new Children();
                Parent             parent      = new Parent();
                foreach (var DA in dailyAlerts)
                {
                    // כאן צריך להוסיף עוד בדיקת תקינות האם כבר נשלח הודעה ומתי
                    DateTime avg = CalculatingTheAverageArrivalOfAchild(DA.ChildId);
                    if (DateTime.Now.TimeOfDay > avg.TimeOfDay && DA.IsComing_ == false && DA.IsMissing_ == false)
                    {
                        List <Message> messages = db.Message.Where(m => m.IDChild == DA.ChildId && m.Date == DateTime.Today).ToList();
                        if (messages.Count() > 0)
                        {
                            DateTime minDate = DateTime.MaxValue;
                            DateTime maxDate = DateTime.MinValue;
                            // לחפש את התאריך תאריך הכי גדול
                            foreach (var M in messages)
                            {
                                // בדיקה האם הודיעה נשלחה לפני יותר מ15 דק אפ כן נשלח הודעה שוב
                                if (M.Date.Value.AddMinutes(15).TimeOfDay > DateTime.Now.TimeOfDay)
                                {
                                    string mailBody = File.ReadAllText(@"C:\Users\טהר אזוט\Documents\פרויקט מעון\KinderGarden\SafetyChildren-Asp-.Net-Web-Api\SaftyChildren\file\messege.html");

                                    children = db.Children.FirstOrDefault(c => c.ChildId == DA.ChildId);
                                    mailBody = mailBody.Replace("@Pname", children.Parent.First().ParentName);
                                    mailBody = mailBody.Replace("@Cname", children.ChildName);
                                    mailBody = mailBody.Replace("@IDChild", children.ChildId.ToString());

                                    //mailBody = mailBody.Replace("@Pname", "שירה ");
                                    //mailBody = mailBody.Replace("@Cname","מיכאל");
                                    sendEmail("*****@*****.**", "הילד שלכם עדין לא הגיע היום!", mailBody);
                                }
                            }
                        }
                        else
                        {
                            children = db.Children.FirstOrDefault(c => c.ChildId == DA.ChildId);
                            string mailBody = File.ReadAllText(@"C:\Users\Shira\Desktop\טוהר\SafetyChildren-Asp-.Net-Web-Api\SaftyChildren\file\messege.html");

                            //mailBody = mailBody.Replace("@Pname", children.Parent.First().ParentName);
                            //mailBody = mailBody.Replace("@Cname", children.ChildName);
                            //mailBody = mailBody.Replace("@Pname", "שירה ");
                            //mailBody = mailBody.Replace("@Cname", "מיכאל");
                            //mailBody = mailBody.Replace("@IDChild", "12");

                            //sendEmail("*****@*****.**", "try", mailBody);
                        }
                    }
                }
            }
            return(true);
        }
 public static bool AddUser(UsrDto us)
 {
     using (kindergardenEntities db = new kindergardenEntities())
     {
         Users poDal = UsrDto.Todal(us);
         int id = 0;
         id += UserDal.AddUser(poDal);
         if (id != 0)
             return true;
     }
     return false;
 }
Пример #8
0
 public static string GetUser(string id)
 {
     using (kindergardenEntities db = new kindergardenEntities())
     {
         string name = PropertyChildrenDal.GetUser(id);
         if (name != null)
         {
             return("Welcome " + name + " To enter press on your child picture");
         }
         return(name);
     }
 }
Пример #9
0
 public static Children Getallpropertyc(string id)
 {
     using (kindergardenEntities db = new kindergardenEntities())
     {
         Children pass = PropertyChildrenDal.Getallpropertyc(id);
         Children c    = new Children();
         c.ChildId    = pass.ChildId;
         c.ChildName  = pass.ChildName;
         c.ChildGroup = pass.ChildGroup;
         c.ChildClass = pass.ChildClass;
         return(c);
     }
 }
        public static bool UpdateUser(UsrDto us)
        {
            using (kindergardenEntities db = new kindergardenEntities())
            {
                bool id = false;
                Users poDal = UsrDto.Todal(us);
                string v = us.childId;
                if (poDal.UserName != null && poDal.Password != null)
                    id = UserDal.UpdateUser(poDal, v);
                return id;

            }
            return false;
        }
Пример #11
0
 public static bool UpdateChildren(PropertyChildrenDto ch)
 {
     using (kindergardenEntities db = new kindergardenEntities())
     {
         bool     id    = false;
         Children poDal = PropertyChildrenDto.ToDal(ch);
         if (poDal.ChildId != null && poDal.ChildClass != null && poDal.ChildGroup != null && poDal.ChildName != null)
         {
             id = PropertyChildrenDal.UpdateChildren(poDal);
         }
         return(id);
     }
     return(false);
 }
 // חישוב ממוצע הגעה של ילד 
 public static DateTime CalculatingTheAverageArrivalOfAchild(int IDChild)
 {
     using (kindergardenEntities db = new kindergardenEntities())
     {
         List<ArrivalChildren> arrivalChildrens = db.ArrivalChildren.Where(c => c.ChildId == IDChild).ToList();
         var count = arrivalChildrens.Count;
         double temp = 0D;
         for (int i = 0; i < count; i++)
         {
             temp += arrivalChildrens[i].ArrivalTime.Value.Ticks / (double)count;
         }
         var average = new DateTime((long)temp);
         return average;
     }
 }
Пример #13
0
 // פונקציה שנשלחת ע"י הלקוח פעם ביום בשעה 6 ומאפסת את אישור הגעת הילד
 public static bool ResetDailyAlerts()
 {
     using (kindergardenEntities db = new kindergardenEntities())
     {
         List <DailyAlerts> dailyAlerts = db.DailyAlerts.ToList();
         foreach (var item in dailyAlerts)
         {
             item.IsComing_       = false;
             item.IsMissing_      = false;
             db.Entry(item).State = EntityState.Modified;
             db.SaveChanges();
         }
     }
     return(true);
 }
Пример #14
0
        // אישור הגעת ילד
        public static bool ConfirmationArrivalChild(int IdChild)
        {
            using (kindergardenEntities db = new kindergardenEntities())
            {
                DailyAlerts dailyAlerts = db.DailyAlerts.FirstOrDefault(d => d.ChildId == IdChild);
                if (dailyAlerts != null)
                {
                    // כאן יש שאלה האם זה מעדכן כל יום איך זה עובד אולי צריך לשעות שינויים בהדעת הילד שיש שם תאריך
                    dailyAlerts.IsMissing_      = true;
                    db.Entry(dailyAlerts).State = EntityState.Modified;// האובייקט הנשלח אמור להתעדכן

                    db.SaveChanges();
                }
                return(true);
            }
        }
Пример #15
0
 public static bool Addtimecoming(int id)
 {
     using (kindergardenEntities db = new kindergardenEntities())
     {
         //ArrivalChildren p = db.ArrivalChildrens.Find(id);
         //db.ArrivalChildrens.Remove(p);
         Children c = null;
         c = db.Children.Find(id);
         if (c != null)
         {
             ArrivalChildren p1 = new ArrivalChildren();
             p1.ChildId     = id;
             p1.Date        = DateTime.Today;
             p1.ArrivalTime = DateTime.Now.TimeOfDay;
             db.ArrivalChildren.Add(p1);
             db.SaveChanges();
             return(true);
         }
         return(false);
     }
 }
Пример #16
0
 public static bool Addtimecoming(int id)
 {
     using (kindergardenEntities db = new kindergardenEntities())
     {