public string AddNewTeacher(string Name, string Surname, string PassportNomber, int IdSchool)
        {
            if (string.IsNullOrEmpty(Name) || string.IsNullOrEmpty(Surname) || string.IsNullOrEmpty(PassportNomber))
            {
                return("All Informations Of Teacher Not Allow To be Empty");
            }
            else
            {
                if (_dalschool.IsExist(IdSchool))
                {
                    if (!_dal.IsExist(Name, Surname))
                    {
                        var teacher = Teacher.CreaTeacher(Name, Surname, PassportNomber);
                        _dal.AddNewTeacher(teacher);
                        var School = _dalschool.GetSchool(IdSchool);

                        _dal.AddNewTeacherSchool(TeacherSchool.CreaTeacherSchool(School, teacher));
                        return("true");
                    }
                    else
                    {
                        return("This Teacher Is  Exist Before");
                    }
                }
                else
                {
                    return("This School Is Not Exist ");
                }
            }
        }
        public string AddNewListStudents(List <DataAPI> dataAPIs)
        {
            var ErrorStrng = "";

            foreach (var item in dataAPIs)
            {
                if (string.IsNullOrEmpty(item.Name) || string.IsNullOrEmpty(item.Surname) || string.IsNullOrEmpty(item.PassportNomber))
                {
                    ErrorStrng += "All Informations Of Student Not Allow To be Empty in Item No :" + item.IdItem + " __ ";
                }
                else
                {
                    if (_dalschool.IsExist(item.IdSchool))
                    {
                        if (!_dal.IsExist(item.Name, item.Surname)) // Not Allow to be more than one Student in same name in DB
                        {
                            var School = _dalschool.GetSchool(item.IdSchool);


                            _dal.AddNewStudent(Student.CreatStudent(item.Name, item.Surname, item.PassportNomber, School));
                        }
                        else
                        {
                            ErrorStrng += "This Student Is  Exist Before in Item No :" + item.IdItem + " __ ";
                        }
                    }
                    else
                    {
                        ErrorStrng += "This School Is Not Exist in Item No :" + item.IdItem + " __ ";
                    }
                }
            }

            if (ErrorStrng == "")
            {
                ErrorStrng = "true";// All Informations is Saved
            }
            return(ErrorStrng);
        }
Exemple #3
0
 public string UpdateSchool(int Id, string Address, string City, string District)
 {
     if (!_dal.IsExist(Id))
     {
         var UpdateSchool = _dal.GetSchool(Id);
         UpdateSchool.Address  = Address;
         UpdateSchool.City     = City;
         UpdateSchool.District = District;
         _dal.UpdateSchool(UpdateSchool);
         return("true");
     }
     else
     {
         return("This School Is Exist Before");
     }
 }