Example #1
0
        public IActionResult Register(StudentDto request)
        {
            var addresses = request.Addresses.Select(a => new Address(a.Street, a.City, a.State, a.ZipCode)).ToList();

            Result <Email, Error> email = Email.Create(request.Email);
            Result <StudentName>  name  = StudentName.Create(request.Name);

            if (email.IsFailure)
            {
                return(BadRequest(email.Error));
            }
            if (name.IsFailure)
            {
                return(BadRequest(name.Error));
            }

            var student = new Student(email.Value, name.Value, request.Phone, addresses);

            _studentRepository.Save(student);

            var response = new RegisterResponse
            {
                Id = student.Id
            };

            return(Ok(response));
        }
Example #2
0
        } //------------------------------

        //this function returns the student name details
        private StudentName GetStudentNameDetails(String studentName)
        {
            if (!String.IsNullOrEmpty(studentName))
            {
                studentName = RemoteClient.ProcStatic.TrimStartEndString(studentName);
            }

            StudentName studInfo = new StudentName();

            String[] splitString = studentName.Split(",(".ToCharArray());

            if (splitString.Length == 1)
            {
                String[] tempString = studentName.Split(" ".ToCharArray());

                for (Int32 i = 0; i <= tempString.Length - 1; i++)
                {
                    if (i == 0)
                    {
                        studInfo.LastName = this.SetFirstLetterToUpper(RemoteClient.ProcStatic.TrimStartEndString(tempString[i]));
                    }
                    else
                    {
                        studInfo.FirstName += this.SetFirstLetterToUpper(tempString[i]) + " ";
                    }
                }

                studInfo.FirstName = RemoteClient.ProcStatic.TrimStartEndString(studInfo.FirstName);
            }
            else
            {
                for (Int32 i = 0; i <= splitString.Length - 1; i++)
                {
                    if (i == 0)
                    {
                        studInfo.LastName = this.SetFirstLetterToUpper(RemoteClient.ProcStatic.TrimStartEndString(splitString[i]));
                    }
                    else if (i == 1)
                    {
                        studInfo.FirstName = this.SetFirstLetterToUpper(RemoteClient.ProcStatic.TrimStartEndString(splitString[i]));
                    }
                    else
                    {
                        String temp = RemoteClient.ProcStatic.TrimStartEndString(splitString[i]);

                        if (temp.Length > 0)
                        {
                            studInfo.Scholoarship += temp.Substring(0, temp.Length - 1) + " ";
                        }
                    }
                }

                if (!String.IsNullOrEmpty(studInfo.Scholoarship))
                {
                    studInfo.Scholoarship = RemoteClient.ProcStatic.TrimStartEndString(studInfo.Scholoarship);
                }
            }

            return(studInfo);
        }//--------------------------
Example #3
0
        //public static List<RicePerson> get(string firstname, string lastname)
        public static List <Student> get(string firstname, string lastname, string college)
        {
            string json = new WebClient().DownloadString(String.Format("{0}firstname={1}&lastname={2}&college={3}",
                                                                       System.Configuration.ConfigurationManager.AppSettings["SearchRicePeopleUrlPrefix"],
                                                                       firstname,
                                                                       lastname,
                                                                       college));
            RootObject     root      = Newtonsoft.Json.JsonConvert.DeserializeObject <RootObject>(json);
            List <Result>  results   = root.results;
            List <Student> returnVal = new List <Student>();

            foreach (Result result in results)
            {
                Student toAdd = new Student();
                toAdd.email = result.email;
                toAdd.netid = result.netid;

                StudentName name  = new StudentName();
                String[]    words = Regex.Split(result.name, ", ");
                name.firstname = words[0];
                name.lastname  = words[words.Length - 1];

                toAdd.full_name = name;
                returnVal.Add(toAdd);
            }
            return(returnVal);
        }
        public override MySearchUtil ToSearchUtil()
        {
            MySearchUtil util = MySearchUtil.New().AndEqual("IsDel", false);

            if (!string.IsNullOrWhiteSpace(Key))
            {
                // util.AndContains(new string[] { "Title", "Name" }, Key.Trim());
            }

            if (SchoolId.HasValue)
            {
                util.AndEqual("SchoolId", SchoolId.Value);
            }

            if (StudentId.HasValue)
            {
                util.AndEqual("StudentId", StudentId.Value);
            }

            if (!string.IsNullOrWhiteSpace(StudentName))
            {
                util.AndContains("StudentName", StudentName.Trim());
            }

            if (!string.IsNullOrWhiteSpace(PaymentMethod))
            {
                util.AndContains("PaymentMethod", PaymentMethod.Trim());
            }

            util.OrderBy(SetOrderBy());

            return(util);
        }
        public string DisplayStudentInfo(int spaces)
        {
            int n1 = StudentName.Length + spaces;
            int n2 = StudentID.Length + spaces;
            int n3 = CalcLetterGrade().Length + spaces;

            return(StudentName.PadRight(n1) + StudentID.PadRight(n2) + CalcLetterGrade().PadRight(n3));
        }
Example #6
0
 public EquivalencePartitionTest()
 {
     _studentName = new StudentName();
     _students    = new List <Student>
     {
         new Student("4094W020"),
         new Student("4094W021"),
     };
 }
Example #7
0
        public void AddStudent(string firstname, string lastname)
        {
            StudentName studentName = new StudentName()
            {
                firstname = firstname,
                lastname  = lastname
            };

            students.Add(studentName);
        }
Example #8
0
 public bool Equals(Student other)
 {
     if (StudentID == other.StudentID && StudentName.ToLower() == other.StudentName.ToLower() && Age == other.Age)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #9
0
        public override int GetHashCode()
        {
            char[] letters  = StudentName.ToArray();
            int    HashCode = 0;

            foreach (char letter in letters)
            {
                HashCode += (int)letter & 0x0f;
            }

            return(HashCode);
        }
        private void GetStudents()
        {
            SqlCommand comm = new SqlCommand("Select * from Students;", connection);

            connection.Open();
            SqlDataReader reader = comm.ExecuteReader();

            StudentName.DataSource = reader;
            StudentName.DataBind();

            connection.Close();
        }
 private void resetFormToolStripMenuItem_Click(object sender, EventArgs e)
 {
     StudentId.Clear();
     StudentName.Clear();
     Std.Clear();
     Div.Clear();
     RollNo.Clear();
     Gender.Clear();
     Category.Clear();
     dob.Clear();
     StudentId.Focus();
 }
Example #12
0
    public void f()
    {
        var st = new StudentName {
            FirstName = "Andy", LastName = "Ruth", ID = 198
        };

        for (int i = 0; i < 100; i++)
        {
            Console.Write("Count " + students.Count);
            //Console.WriteLine("     Capacity " + students.Capacity);
            intDict.Add(i, 4);
        }
    }
Example #13
0
        private static void Tuples_DeconstructionOfTuples()
        {
            HelperClass helperClass = new HelperClass();
            var         studentInfo = helperClass.ReturnStudentInfo();

            Console.WriteLine($"From Tuples... The Student with {studentInfo.name} & Age {studentInfo.age} & Grade {studentInfo.grade}");

            (string StudentName, int StudentAge, string StudentGrade) = helperClass.ReturnStudentInfo();
            if (StudentName.Contains("M"))
            {
                Console.WriteLine($"From DeconstructionOfTuples... The Student with {StudentName} & Age {StudentAge} & Grade {StudentGrade}");
            }
            Console.WriteLine();
        }
        string GetStudentShortName()
        {
            string[] ele  = StudentName.Trim().Split(new char[] { ' ' });
            int      size = ele.Length;

            string remain = "";

            for (int i = 0; i < size - 1; i++)
            {
                remain += ele[i][0];
            }
            remain = remain.ToUpper();

            return(convertToUnSign3(ele[size - 1] + remain + StudentCode.ToUpper()));
        }
Example #15
0
        private static Student Alice()
        {
            var email = Email.Create("*****@*****.**");
            var name  = StudentName.Create("Alice Alison");
            var alice = new Student(email.Value, name.Value, "202-555-1234",
                                    new List <Address>
            {
                new Address("1234 Main St", "Arlington", "VA", "22201")
            }
                                    );

            SetId(alice, 1);
            alice.Enroll(new Course(1, "Calculus", 5), Grade.A);

            return(alice);
        }
Example #16
0
        private static Student Bob()
        {
            var email = Email.Create("*****@*****.**");
            var name  = StudentName.Create("Bob Bobson");
            var bob   = new Student(email.Value, name.Value, "305-555-6688",
                                    new List <Address>
            {
                new Address("2345 Second St", "Barlington", "VA", "22202")
            }
                                    );

            SetId(bob, 2);
            bob.Enroll(new Course(2, "History", 4), Grade.B);

            return(bob);
        }
        private async void StudentsSearchList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var metroWindow = (Window.GetWindow(this) as MetroWindow);
            var student     = StudentsSearchList.SelectedItem as Voter;

            if (student != null)
            {
                var dialogSettings = new MetroDialogSettings {
                    DialogMessageFontSize = 20, AffirmativeButtonText = "Ok"
                };
                await metroWindow.ShowMessageAsync($"Name:{student.VoterName}", $"Password: {student.VoterCode}", MessageDialogStyle.Affirmative, dialogSettings);

                StudentName.Text = String.Empty;
                StudentName.Focus();
            }
        }
Example #18
0
        static void Main(string[] args)
        {
            var Jeffrey = new StudentName();

            Jeffrey.FirstName = "Jeffrey";
            Jeffrey.LastName  = "Chen";

            Jeffrey.Introduce();


            var calculator = new Calculator();

            var result = calculator.Add(1, 2);

            Console.WriteLine(result);
            Console.ReadLine();
        }
    public static void Main()
    {
        // Declare a StudentName by using the constructor that has two parameters.
                        StudentName student1 = new StudentName("Craig", "Playstead");

                        // Make the same declaration by using an object initializer and sending
                        // arguments for the first and last names. The default constructor is
                        // invoked in processing this declaration, not the constructor that has
                        // two parameters.
                        StudentName student2 = new StudentName
                        {
                            FirstName = "Craig",
                            LastName = "Playstead",
                        };

                        // Declare a StudentName by using an object initializer and sending
                        // an argument for only the ID property. No corresponding constructor is
                        // necessary. Only the default constructor is used to process object
                        // initializers.
                        StudentName student3 = new StudentName
                        {
                            ID = 183
                        };

                        // Declare a StudentName by using an object initializer and sending
                        // arguments for all three properties. No corresponding constructor is
                        // defined in the class.
                        StudentName student4 = new StudentName
                        {
                            FirstName = "Craig",
                            LastName = "Playstead",
                            ID = 116
                        };

                        System.Console.WriteLine(student1.ToString());
                        System.Console.WriteLine(student2.ToString());
                        System.Console.WriteLine(student3.ToString());
                        System.Console.WriteLine(student4.ToString());
    }
Example #20
0
        public static void Main()
        {
            // Declare a StudentName by using the constructor that has two parameters.
            StudentName student1 = new StudentName("Craig", "Playstead");

            // Make the same declaration by using an object initializer and sending
            // arguments for the first and last names. The default constructor is
            // invoked in processing this declaration, not the constructor that has
            // two parameters.
            StudentName student2 = new StudentName
            {
                FirstName = "Craig",
                LastName  = "Playstead",
            };

            // Declare a StudentName by using an object initializer and sending
            // an argument for only the ID property. No corresponding constructor is
            // necessary. Only the default constructor is used to process object
            // initializers.
            StudentName student3 = new StudentName
            {
                ID = 183
            };

            // Declare a StudentName by using an object initializer and sending
            // arguments for all three properties. No corresponding constructor is
            // defined in the class.
            StudentName student4 = new StudentName
            {
                FirstName = "Craig",
                LastName  = "Playstead",
                ID        = 116
            };

            Console.WriteLine(student1.ToString());
            Console.WriteLine(student2.ToString());
            Console.WriteLine(student3.ToString());
            Console.WriteLine(student4.ToString());
        }
Example #21
0
        /// <summary>Инициализация нового студента</summary>
        /// <param name="data">Массив с элементами данных студента в текстовом виде</param>
        /// <exception cref="ArgumentNullException">Если data == null</exception>
        /// <exception cref="ArgumentException">Если data.Length != 9</exception>
        public Student(string[] data)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }
            if (data.Length != 9)
            {
                throw new ArgumentException("Размер массива данных не равен 9", nameof(data));
            }

            Name = new StudentName
            {
                FirstName  = data[0],
                SecondName = data[1]
            };
            Age         = int.Parse(data[2]);
            Univercity  = data[3];
            Faculty     = data[4];
            Departament = data[5];
            Course      = int.Parse(data[6]);
            Group       = data[7];
            City        = data[8];
        }
Example #22
0
 static void Main(string[] args)
 {
     var student1 = new StudentName("Hello","World");
         var student2 = new StudentName { FirstName = "Hello", LastName = "World" };//对象初始化器 调用SutdentName()构造函数
         var student3 = new StudentName("Hello", "World") { ID = 101 };
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["New"] != null)
        {
            reportName.Text = Session["New"].ToString();
        }
        else
        {
            Response.Redirect("Default.aspx");
        }

        if (!this.IsPostBack)
        {
            string constr = ConfigurationManager.ConnectionStrings["DeptConnections"].ConnectionString;
            using (SqlConnection con = new SqlConnection(constr))
            {
                using (SqlCommand cmd = new SqlCommand("SELECT courseID FROM usercourse where username='******'"))
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.Connection  = con;
                    con.Open();
                    ddlcourses.DataSource     = cmd.ExecuteReader();
                    ddlcourses.DataTextField  = "courseID";
                    ddlcourses.DataValueField = "courseID";
                    ddlcourses.DataBind();
                    con.Close();
                }
                using (SqlCommand cmd = new SqlCommand("SELECT distinct(courseID) FROM usercourse where username='******'"))
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.Connection  = con;
                    con.Open();
                    ddlReport.DataSource     = cmd.ExecuteReader();
                    ddlReport.DataTextField  = "courseID";
                    ddlReport.DataValueField = "courseID";
                    ddlReport.DataBind();
                    con.Close();
                }
                using (SqlCommand cmd = new SqlCommand("select distinct[username] from usercourse where courseID = '" + Request.QueryString["RValue"].ToString() + "' and professor = '" + Session["New"] + "' and professor!=username"))
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.Connection  = con;
                    con.Open();
                    StudentName.DataSource     = cmd.ExecuteReader();
                    StudentName.DataTextField  = "username";
                    StudentName.DataValueField = "username";
                    StudentName.DataBind();
                    con.Close();
                }
                using (SqlCommand cmd = new SqlCommand("SELECT distinct(courseID) FROM usercourse where username='******'"))
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.Connection  = con;
                    con.Open();
                    ddlReportview.DataSource     = cmd.ExecuteReader();
                    ddlReportview.DataTextField  = "courseID";
                    ddlReportview.DataValueField = "courseID";
                    ddlReportview.DataBind();
                    con.Close();
                }
            }
            ddlcourses.Items.Insert(0, new ListItem("--Course Details--", "0"));
            ddlReport.Items.Insert(0, new ListItem("Create A Report", "0"));
            StudentName.Items.Insert(0, new ListItem("--Select student--", "0"));
            ddlReportview.Items.Insert(0, new ListItem("View Report", "0"));
        }
    }
 private void frmStudentRegistration_Load(object sender, EventArgs e)
 {
     AutocompleCourse();
     StudentName.Focus();
 }
Example #25
0
        private void AddParentInDb()
        {
            // NAME
            try
            {
                parentRegisterController.SetName(FullName);
                if (FullName.Split(' ').ToList().Count > 3)
                {
                    throw new Exception();
                }
                if (parentRegisterController.ParentNameExists(FullName))
                {
                    MessageBox.Show("Parent already exists!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Wrong Name Format!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            // EGN
            if (parentRegisterController.IsValidEGN(EGN))
            {
                if (parentRegisterController.CheckEGNExists(EGN) == false)
                {
                    parentRegisterController.SetEGN(EGN);
                }
                else
                {
                    MessageBox.Show("EGN is already used!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                MessageBox.Show("EGN is not valid!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            // Lydia Gilmore Kelley
            // 3376299241
            // STUDENT EGN
            if (parentRegisterController.IsValidEGN(StudentEGN))
            {
                if (parentRegisterController.CheckStudentEGNExists(StudentEGN))
                {
                    parentRegisterController.SetStudentEGN(StudentEGN);
                }
                else
                {
                    MessageBox.Show("No such student EGN!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                MessageBox.Show("Student EGN is not valid!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            // STUDENT NAME
            try
            {
                var test = StudentName.Split(' ').ToList();
                if (test.Count != 3)
                {
                    throw new Exception();
                }
                else
                if (parentRegisterController.ParentNameIsCorrect(StudentName, StudentEGN))
                {
                    parentRegisterController.SetStudentName(StudentName);
                }
                else
                {
                    MessageBox.Show("No such student!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Wrong student name format!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            parentRegisterController.AddParent();
            MessageBox.Show("Success!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
 override public void AddStudent(StudentName sn, int f)
 {
     base.AddStudent(sn, 0);
 }
 override public void AddStudent(StudentName sn, int f)
 {
     //Add student
 }
 public override void AddStudent(StudentName sn, int f)
 {
     //do stuff
 }
 public abstract void AddStudent(StudentName sn, int f);
 public IQueryable <InternshipCourse> ApplyTo(IQueryable <InternshipCourse> InternshipCourses)
 {
     if (StudentId != Guid.Empty)
     {
         InternshipCourses = InternshipCourses.Where(m => m.StudentId.Equals(StudentId));
     }
     if (!string.IsNullOrEmpty(StudentName))
     {
         InternshipCourses = InternshipCourses.Where(m => m.Student.FullName.ToLower().Contains(StudentName.ToLower()));
     }
     if (!string.IsNullOrEmpty(CompanyName))
     {
         InternshipCourses = InternshipCourses.Where(m => m.Company.Name.ToLower().Contains(CompanyName.ToLower()));
     }
     return(InternshipCourses);
 }
Example #31
0
        } //------------------------

        //this procedure exports the student data to the sql server
        private void ExportStudentDataToSqlServer()
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                Int32 deniedCount  = 0;
                Int32 successCount = 0;
                Int32 rowCount     = 0;

                pgbImport.Step    = 1;
                pgbImport.Maximum = this.dgvList.Rows.Count;

                foreach (DataRow studRow in _studentTable.Rows)
                {
                    this.SetDataGridViewBehavior(rowCount);

                    String studentId   = RemoteServerLib.ProcStatic.DataRowConvert(studRow, "ACCESSION", "");
                    String cardNumber  = RemoteServerLib.ProcStatic.DataRowConvert(studRow, "KEYWORDS", "");
                    String studentName = RemoteServerLib.ProcStatic.DataRowConvert(studRow, "TITLE0", "");

                    if (!this.IsExistStudentIdStudentInformation(_userInfo, studentId, "") &&
                        !this.IsExistCardNumberStudentInformation(_userInfo, cardNumber, "") &&
                        !String.Equals("(blank)", studentName) &&
                        !String.IsNullOrEmpty(RemoteClient.ProcStatic.TrimStartEndString(cardNumber)) &&
                        !String.IsNullOrEmpty(RemoteClient.ProcStatic.TrimStartEndString(studentId)))
                    {
                        String remarks = RemoteServerLib.ProcStatic.DataRowConvert(studRow, "REMARKS", "");

                        CommonExchange.Student studentInfo = new CommonExchange.Student();

                        studentInfo.ObjectState            = DataRowState.Added;
                        studentInfo.PersonInfo.ObjectState = DataRowState.Added;

                        StudentName    studName   = this.GetStudentNameDetails(studentName);
                        RemarksDetails remarkInfo = this.GetRemarksDetails(remarks);

                        studentInfo.StudentId            = RemoteClient.ProcStatic.TrimStartEndString(studentId);
                        studentInfo.PersonInfo.LastName  = studName.LastName;
                        studentInfo.PersonInfo.FirstName = studName.FirstName;
                        studentInfo.CardNumber           = cardNumber;
                        studentInfo.Scholarship          = studName.Scholoarship;
                        studentInfo.CourseInfo.CourseId  = this.GetCourseId(remarkInfo.CourseName);
                        studentInfo.PersonInfo.OtherPersonInformation = remarkInfo.OtherInformation;
                        studentInfo.PersonInfo.BirthDate = String.Empty;

                        if (!String.IsNullOrEmpty(_imagePath) && this.chkImage.Checked)
                        {
                            StudentImage imageInfo = this.GetStudentImageDetails(studentId);

                            if (!String.IsNullOrEmpty(imageInfo.ImagePath))
                            {
                                studentInfo.PersonInfo.FilePath      = imageInfo.ImagePath;
                                studentInfo.PersonInfo.FileData      = RemoteClient.ProcStatic.GetFileArrayBytes(imageInfo.ImagePath);
                                studentInfo.PersonInfo.FileExtension = imageInfo.ImageExtension;
                                studentInfo.PersonInfo.FileName      = Path.GetFileName(imageInfo.ImagePath);

                                this.txtDirectory.Text = imageInfo.ImagePath;
                            }
                        }

                        using (RemoteClient.RemCntStudentManager remClient = new RemoteClient.RemCntStudentManager())
                        {
                            remClient.InsertStudentInformation(_userInfo, ref studentInfo);
                        }

                        using (RemoteClient.RemCntIdMakerManager remClient = new RemoteClient.RemCntIdMakerManager())
                        {
                            remClient.UpdateForIdMakerStudentInformation(_userInfo, studentInfo);
                        }

                        successCount++;
                    }
                    else
                    {
                        deniedCount++;
                    }

                    pgbImport.PerformStep();

                    rowCount++;

                    Application.DoEvents();
                    this.Refresh();
                }

                MessageBox.Show("Student data has been successfully exported to the SQL Server" + "\n\nSuccess: " + successCount.ToString() + " Record(s)" +
                                "\nDenied: " + deniedCount.ToString() + " Record(s)", "Success", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

                pgbImport.Value = 0;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in exporting: " + ex.Message, "Error");
            }
            finally
            {
                this.Cursor = Cursors.Arrow;
            }
        } //--------------------------------------
 private void AdminDispensePasswordWindow_Loaded(object sender, RoutedEventArgs e)
 {
     StudentName.Focus();
     RefreshStudentList();
 }