/// <summary>
        /// Evaluates all students details and return them.
        /// </summary>
        /// <param name="details">contains student details</param>
        /// <returns>returns student information<</returns>
        public StudentsDetails GetStudentInfoInReverse(StudentsDetails details)
        {
            details.FullName     = reverseString(details.FullName);
            details.EmailAddress = reverseString(details.EmailAddress);
            details.PhoneNumber  = reverseString(details.PhoneNumber);
            details.Notes        = reverseString(details.Notes);

            return(details);
        }
示例#2
0
        /// <summary>
        /// this action will validate parameters and
        /// if they are not valid then will send 400 Bad Request.
        /// Also, if we are receving empty string in any parameter then
        /// we do not send that parameter in response.
        /// </summary>
        /// <param name="details">contains student details</param>
        /// <returns>returns student information</returns>
        public IActionResult GetStudentDetailInReverse([FromForm] StudentsDetails details)
        {
            StudentsDetails students = new StudentsDetails();

            StudentService.StudentService stdService = new StudentService.StudentService();
            students = stdService.GetStudentInfoInReverse(details);

            return(Ok(students));
        }
        public List <StudentsDetails> ReadUploadedExcelTest(HttpPostedFile file)
        {
            var usersList = new List <StudentsDetails>();

            using (var package = new ExcelPackage(file.InputStream))
            {
                var currentSheet = package.Workbook.Worksheets;
                var workSheet    = currentSheet.First();
                var noOfCol      = workSheet.Dimension.End.Column;
                var noOfRow      = workSheet.Dimension.End.Row;
                //json = new JavaScriptSerializer().Serialize(workSheet);
                for (int rowIterator = 2; rowIterator <= noOfRow; rowIterator++)
                {
                    var user = new StudentsDetails();
                    // user.ClientId =Convert.ToInt32( workSheet.Cells[rowIterator, 1].Value.ToString());
                    user.Clients.ClientID = workSheet.Cells[rowIterator, 1].Value != null?Convert.ToInt32(workSheet.Cells[rowIterator, 1].Value.ToString()) : 0;

                    //students persoal details
                    user.StudPersonalDetails.Name       = workSheet.Cells[rowIterator, 2].Value != null ? workSheet.Cells[rowIterator, 2].Value.ToString() : "";
                    user.StudPersonalDetails.MiddleName = workSheet.Cells[rowIterator, 3].Value != null ? workSheet.Cells[rowIterator, 3].Value.ToString() : "";
                    user.StudPersonalDetails.LastName   = workSheet.Cells[rowIterator, 4].Value != null ? workSheet.Cells[rowIterator, 4].Value.ToString() : "";
                    user.StudPersonalDetails.FatherName = workSheet.Cells[rowIterator, 5].Value != null ? workSheet.Cells[rowIterator, 5].Value.ToString() : "";
                    user.StudPersonalDetails.MotherName = workSheet.Cells[rowIterator, 6].Value != null ? workSheet.Cells[rowIterator, 6].Value.ToString() : "";
                    user.StudPersonalDetails.DOB        = workSheet.Cells[rowIterator, 7].Value != null ? workSheet.Cells[rowIterator, 7].Value.ToString() : "0000-00-00";
                    //students Contacts
                    user.StudentContacts.Phone          = workSheet.Cells[rowIterator, 8].Value != null ? workSheet.Cells[rowIterator, 8].Value.ToString() : "";;
                    user.StudentContacts.AlternatePhone = workSheet.Cells[rowIterator, 9].Value != null ? workSheet.Cells[rowIterator, 9].Value.ToString() : "";;
                    user.StudentContacts.Email          = workSheet.Cells[rowIterator, 10].Value != null ? workSheet.Cells[rowIterator, 10].Value.ToString() : "";;
                    //Students Address
                    user.StudentAddress.Address1 = workSheet.Cells[rowIterator, 11].Value != null ? workSheet.Cells[rowIterator, 11].Value.ToString() : "";;
                    user.StudentAddress.Address2 = workSheet.Cells[rowIterator, 12].Value != null ? workSheet.Cells[rowIterator, 12].Value.ToString() : "";;
                    user.StudentAddress.City     = workSheet.Cells[rowIterator, 13].Value != null ? workSheet.Cells[rowIterator, 13].Value.ToString() : "";;
                    user.StudentAddress.State    = workSheet.Cells[rowIterator, 14].Value != null ? workSheet.Cells[rowIterator, 14].Value.ToString() : "";;
                    user.StudentAddress.PIN      = workSheet.Cells[rowIterator, 15].Value != null?Convert.ToInt32(workSheet.Cells[rowIterator, 15].Value.ToString()) : 000000;;

                    // course Details
                    user.CourseDetails.CourseID   = workSheet.Cells[rowIterator, 16].Value != null?Convert.ToInt32(workSheet.Cells[rowIterator, 16].Value.ToString()) : 00;;
                    user.CourseDetails.CourseName = workSheet.Cells[rowIterator, 17].Value != null ? workSheet.Cells[rowIterator, 17].Value.ToString() : "";;



                    usersList.Add(user);
                }
            }
            return(usersList);
        }