//public List<string> OptionalGrades { get; set; }
 //public List<string> OptionalClasses { get; set; }
 public CounslerBranchModelToView(CounslerModel Counsler, BranchModel Branch)
 {
     if (Counsler == null)
          Counsler = new CounslerModel();
      this.Counsler = Counsler;
      if (Branch == null)
          Branch = new BranchModel();
      this.Branch = Branch;
 }
 public static void UpdateCounslerGroup(int groupId, CounslerModel counsler)
 {
     CounslerModel t = null;
     if (counsler != null &&
        ClassPickUpDic.TryGetValue(groupId, out t))
     {
         ClassPickUpDic[groupId] = counsler;
     }
 }
        internal static List<CounslerModel> GetCounslersData()
        {
            List<CounslerModel> list = new List<CounslerModel>();
            var tempCounslerSchedule = ApplicationContext.Instnace.contextInstance.counslers_schedule.ToList();

            ApplicationContext.Instnace.contextInstance.counslers.ToList().ForEach(c =>
            {
                CounslerModel tempCounsler = new CounslerModel()
                {
                    Birthday = c.birthday,
                    ID = c.id,
                    FirstName = c.first_name,
                    LastName = c.last_name,
                    UserName = c.usernmae,
                    DefaultGrade = c.default_grade,
                    DefaultClass = c.default_class,
                    PhoneNumber = c.phone_mobile,
                    Email1 = c.email_1,
                };
                try
                {
                    tempCounsler.AllowedBranchedIds = c.allowed_branches.Split(',').Select(branch => Convert.ToInt32(branch)).ToList();
                    int dayOfWeek = (int)DateTime.Now.DayOfWeek;
                    dayOfWeek = 1;
                    tempCounsler.WhereAmI = tempCounslerSchedule.Where(counsler => (counsler.counsler_id == c.id && counsler.day == dayOfWeek)).Select(counsler =>
                        {
                            return new CCounslersScheduleModel()
                            {
                                Hour = counsler.hour_num,
                                Acticity = counsler.activity,
                                Comment = counsler.comment,
                                Day = counsler.day,
                                Group = counsler.group,
                                Location = counsler.location,
                                HourDescription = counsler.hour_desc_

                            };

                        }).ToList();
                }
                catch (Exception ex)
                {
                    Logger.WriteToLog(LogLevel.error, "GetCounslersData converting branch ids", ex);
                }
                list.Add(tempCounsler);

            });
            return list;
        }
 internal void SetStudentPickedUp(CounslerModel counsler, string pickerName)
 {
     this.PickUp = new CheckedInOutModel() { ByWhom = pickerName, CounslerId = counsler.ID, When = DateTime.Now, IsByOther = IsPickedByOther(pickerName) };
     DataAccess.StudentPickedUp(counsler.ID, this.ID, pickerName, PickUp.IsByOther);
 }
 internal void SetStudentCheckedIn(CounslerModel counsler)
 {
     this.CheckedIn = new CheckedInOutModel() { CounslerId = counsler.ID, When = DateTime.Now, ByWhom=counsler.FirstName+" "+counsler.LastName };
     DataAccess.StudentCheckedIn(counsler.ID, this.ID);
 }
 public StudentCounslerModelToView(StudentModel Student, CounslerModel Counsler)
 {
     this.Counsler = Counsler;
     this.Student = Student;
 }
 //public List<string> OptionalGrades { get; set; }
 //public List<string> OptionalClasses { get; set; }
 public CounslerInfoModelToView(CounslerModel Counsler,int BranchId=0)
 {
     this.Counsler = Counsler;
     this.GradeAndClasses=InMemoryHandler.GetAvaiableGradeAndClass(BranchId);
 }
 public StudentLightModelToView(List<StudentLight> StudentsLight, CounslerModel Counsler)
 {
     this.Counsler = Counsler;
     this.StudentsLight=StudentsLight;
 }
        internal static List<CounslerModel> GetCounslersData()
        {
            List<CounslerModel> list = new List<CounslerModel>();
            ApplicationContext.Instnace.contextInstance.counslers.ToList().ForEach(c =>
            {
                contacts counslerBase = InMemoryHandler.GetContactById(c.counsler_concacts_id);
                if (c == null)
                {
                    return;
                }
                CounslerModel tempCounsler = new CounslerModel()
                {
                    Birthday = c.birthday,
                    CounslerID = counslerBase.id,
                    FirstName = counslerBase.first_name,
                    LastName = counslerBase.last_name,
                    UserName = c.usernmae
                };
                try
                {
                    tempCounsler.AllowedBranchedIds = c.allowed_branches.Split(',').Select(branch => Convert.ToInt32(branch)).ToList();
                }
                catch (Exception ex)
                {
                    Logger.WriteToLog(LogLevel.error, "GetCounslersData converting branch ids", ex);
                }
                list.Add(tempCounsler);

            });
            return list;
        }