示例#1
0
        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);
        }