public HttpResponseMessage GetData(string package = "")
        {
            StudentService.StudentService ss = new StudentService.StudentService();
            string cookieValue = String.Empty;

            string[] packageDecode = null;
            string   applicationId = String.Empty;
            string   userId        = String.Empty;
            string   verifyCode    = String.Empty;

            if (!String.IsNullOrEmpty(package))
            {
                try
                {
                    packageDecode = ss.DecodeBase64String(package).Split('.');
                    cookieValue   = ss.DecodeBase64String(ss.StringReverse(packageDecode[0]));

                    if (iUtil.CompareCookie(iUtil.cookieName, cookieValue))
                    {
                        applicationId = ss.DecodeBase64String(ss.StringReverse(packageDecode[1]));
                        userId        = ss.DecodeBase64String(ss.StringReverse(packageDecode[2]));
                        verifyCode    = ss.DecodeBase64String(ss.StringReverse(packageDecode[3]));
                    }
                }
                catch
                {
                }
            }

            DataTable dt = API.Models.Application.GetData(applicationId, userId, verifyCode).Tables[0];

            return(Request.CreateResponse(HttpStatusCode.OK, iUtil.APIResponse.GetData(dt)));
        }
Example #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 static DataSet GetListData(
            string keyword,
            string cancelledStatus,
            string sortOrderBy,
            string sortExpression
            )
        {
            StudentService.StudentService ss = new StudentService.StudentService();
            DataSet ds = ss.GetListCountry(iUtil.infinityConnectionString, keyword, cancelledStatus, sortOrderBy, sortExpression);

            return(ds);
        }
Example #4
0
        public HttpResponseMessage SetTermServiceConsent()
        {
            string        userId          = String.Empty;
            string        termServiceType = String.Empty;
            StringBuilder xmlData         = new StringBuilder();

            try
            {
                dynamic json    = GetJSONFromRequest();
                string  package = json["package"];

                StudentService.StudentService ss = new StudentService.StudentService();
                string[] packageDecode           = null;
                string   cookieValue             = String.Empty;

                if (!String.IsNullOrEmpty(package))
                {
                    packageDecode = ss.DecodeBase64String(package).Split('.');
                    cookieValue   = ss.DecodeBase64String(ss.StringReverse(packageDecode[0]));

                    if (iUtil.CompareCookie(iUtil.cookieName, cookieValue))
                    {
                        userId          = ss.DecodeBase64String(ss.StringReverse(packageDecode[1]));
                        termServiceType = ss.DecodeBase64String(ss.StringReverse(packageDecode[2]));
                    }
                }
            }
            catch
            {
            }

            if (!String.IsNullOrEmpty(userId) && !String.IsNullOrEmpty(termServiceType))
            {
                xmlData.AppendFormat(
                    "<table>" +
                    "<row>" +
                    "<studentId>{0}</studentId>" +
                    "<termType>{1}</termType>" +
                    "<termStatus>Y</termStatus>" +
                    "<ip>{2}</ip>" +
                    "<createdBy>{3}</createdBy>" +
                    "</row>" +
                    "</table>", userId, termServiceType, iUtil.GetIP(), userId
                    );
            }

            DataSet ds = iUtil.ExecuteCommandStoredProcedure(iUtil.infinityConnectionString, "sp_stdSetStudentTermService",
                                                             new SqlParameter("@xmlData", (!String.IsNullOrEmpty(xmlData.ToString()) ? xmlData.ToString() : null))
                                                             );

            return(Request.CreateResponse(HttpStatusCode.OK, iUtil.APIResponse.GetData(ds.Tables[0])));
        }
        public static bool CompareCookie(string cookieName, string cookieSource)
        {
            StudentService.StudentService ss = new StudentService.StudentService();
            string cookieValue = ss.ConvertAsciiToString(HttpContext.Current.Request.Cookies[cookieName].Value.ToString());

            cookieValue = cookieValue.Replace("key", "");
            cookieValue = cookieValue.Replace("{", "");
            cookieValue = cookieValue.Replace("}", "");
            cookieValue = cookieValue.Replace(":", "");
            cookieValue = cookieValue.Replace("\"", "");

            return(cookieSource.Equals(cookieValue) ? true : false);
        }
Example #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string what          = Request.QueryString["what"];
            string package       = Request.QueryString["package"];
            string fileName      = (DateTime.Now).ToString("dd-MM-yyyy@HH-mm-ss", new CultureInfo("en-US"));
            string saveFile      = String.Empty;
            string cookieValue   = String.Empty;
            string userId        = String.Empty;
            string applicationId = String.Empty;
            string verifyCode    = String.Empty;

            string[] packageDecode             = null;
            bool     status                    = true;
            Dictionary <string, object> result = new Dictionary <string, object>();
            JavaScriptSerializer        json   = new JavaScriptSerializer();

            StudentService.StudentService ss = new StudentService.StudentService();

            try
            {
                packageDecode = ss.DecodeBase64String(package).Split('.');
                cookieValue   = ss.DecodeBase64String(ss.StringReverse(packageDecode[0]));
                userId        = ss.DecodeBase64String(ss.StringReverse(packageDecode[1]));
                applicationId = ss.DecodeBase64String(ss.StringReverse(packageDecode[2]));

                if (iUtil.CompareCookie(iUtil.cookieName, cookieValue))
                {
                    FileInfo f = new FileInfo(Request.Files[0].FileName);

                    fileName = (applicationId + what + fileName + f.Extension.ToLower());
                    saveFile = (Server.MapPath("~").Replace("API", "").Replace("Publish", "") + iUtil.fileUploadPath + "/" + fileName);

                    Request.Files[0].SaveAs(saveFile);

                    status = true;
                }
                else
                {
                    status = false;
                }
            }
            catch
            {
                status = false;
            }

            result.Add("status", status);
            result.Add("fileName", fileName);

            Response.Write(json.Serialize(result));
        }
Example #7
0
        public HttpResponseMessage GetData(
            string package         = "",
            string sendEmailStatus = "",
            string email           = ""
            )
        {
            StudentService.StudentService ss = new StudentService.StudentService();
            string[] packageDecode           = null;
            string   action     = String.Empty;
            string   userId     = String.Empty;
            string   username   = String.Empty;
            string   password   = String.Empty;
            string   verifyCode = String.Empty;

            if (!String.IsNullOrEmpty(package))
            {
                try
                {
                    packageDecode = ss.DecodeBase64String(package).Split('.');
                    action        = ss.DecodeBase64String(ss.StringReverse(packageDecode[packageDecode.GetLength(0) - 1]));

                    if (action.Equals("signin"))
                    {
                        username = ss.DecodeBase64String(ss.StringReverse(packageDecode[0]));
                        password = ss.DecodeBase64String(ss.StringReverse(packageDecode[1]));
                    }

                    if (action.Equals("info"))
                    {
                        userId     = ss.DecodeBase64String(ss.StringReverse(packageDecode[0]));
                        verifyCode = ss.DecodeBase64String(ss.StringReverse(packageDecode[1]));
                    }

                    if (action.Equals("requestPassword"))
                    {
                        username   = ss.DecodeBase64String(ss.StringReverse(packageDecode[0]));
                        verifyCode = ss.DecodeBase64String(ss.StringReverse(packageDecode[1]));
                    }
                }
                catch
                {
                }
            }

            DataTable dt = API.Models.User.GetData(userId, username, password, verifyCode, sendEmailStatus, email).Tables[0];

            return(Request.CreateResponse(HttpStatusCode.OK, iUtil.APIResponse.GetData(dt)));
        }
Example #8
0
        public HttpResponseMessage GetListData()
        {
            StudentService.StudentService ss = new StudentService.StudentService();
            DataTable dt = new DataTable();
            int       i  = 1;

            dt.Columns.Add("id");
            dt.Columns.Add("name");

            for (i = 1; i <= 8; i++)
            {
                DataRow dr = dt.NewRow();

                dr["id"]   = i.ToString();
                dr["name"] = (i.ToString() + ss.GetOrdinal(i.ToString()));

                dt.Rows.Add(dr);
            }

            return(Request.CreateResponse(HttpStatusCode.OK, iUtil.APIResponse.GetData(dt)));
        }
Example #9
0
        public HttpResponseMessage GetExist(
            string package    = "",
            string packageOld = "",
            string verifyCode = ""
            )
        {
            StudentService.StudentService ss = new StudentService.StudentService();
            string[] packageDecode           = null;
            string[] packageOldDecode        = null;
            string   userId   = String.Empty;
            string   username = String.Empty;
            string   password = String.Empty;

            try
            {
                if (!String.IsNullOrEmpty(package))
                {
                    packageDecode = ss.DecodeBase64String(package).Split('.');
                    username      = ss.DecodeBase64String(ss.StringReverse(packageDecode[0]));
                    password      = ss.DecodeBase64String(ss.StringReverse(packageDecode[1]));
                }
                if (!String.IsNullOrEmpty(packageOld))
                {
                    packageOldDecode = ss.DecodeBase64String(packageOld).Split('.');
                    userId           = ss.DecodeBase64String(ss.StringReverse(packageOldDecode[0]));
                    username         = ss.DecodeBase64String(ss.StringReverse(packageOldDecode[1]));
                    password         = ss.DecodeBase64String(ss.StringReverse(packageOldDecode[2]));
                }
            }
            catch
            {
            }

            DataTable dt = API.Models.User.GetExist(userId, username, password, verifyCode).Tables[0];

            return(Request.CreateResponse(HttpStatusCode.OK, iUtil.APIResponse.GetData(dt)));
        }
        public static void ViewFile(string filePath, string fileName)
        {
            bool fileExist = File.Exists(filePath + "/" + fileName);

            StudentService.StudentService ss = new StudentService.StudentService();

            fileName = (fileExist.Equals(true) ? fileName : "NoFile.png");

            try
            {
                if (!String.IsNullOrEmpty(fileName))
                {
                    string[] viewFileArray = fileName.Split('.');
                    string   fileExtension = viewFileArray[viewFileArray.GetLength(0) - 1];

                    FileStream sourceFile = new FileStream((filePath + "/" + fileName), FileMode.Open);
                    float      fileSize   = sourceFile.Length;
                    byte[]     getContent = new byte[(int)fileSize];
                    sourceFile.Read(getContent, 0, (int)fileSize);
                    sourceFile.Close();

                    HttpContext.Current.Response.ClearContent();
                    HttpContext.Current.Response.ClearHeaders();
                    HttpContext.Current.Response.Buffer      = true;
                    HttpContext.Current.Response.ContentType = ss.GetHeaderContentType(fileExtension.ToLower());
                    HttpContext.Current.Response.AddHeader("Content-Length", getContent.Length.ToString());
                    HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
                    HttpContext.Current.Response.BinaryWrite(getContent);
                    HttpContext.Current.Response.Flush();
                    HttpContext.Current.Response.End();
                }
            }
            catch
            {
            }
        }
Example #11
0
        public static DataSet SetData(string method, List <User> data)
        {
            string action = String.Empty;

            string[] packageDecode = null;
            string   userId        = String.Empty;
            string   username      = String.Empty;
            string   password      = String.Empty;
            string   verifyCode    = String.Empty;
            DataSet  ds            = new DataSet();

            StudentService.StudentService ss = new StudentService.StudentService();

            if (method.Equals("POST"))
            {
                action = "INSERT";
            }
            if (method.Equals("PUT"))
            {
                action = "UPDATE";
            }
            if (method.Equals("DELETE"))
            {
                action = "DELETE";
            }

            foreach (var d in data)
            {
                try
                {
                    packageDecode = ss.DecodeBase64String(d.package).Split('.');

                    if (action.Equals("INSERT"))
                    {
                        username = ss.DecodeBase64String(ss.StringReverse(packageDecode[0]));
                        password = ss.DecodeBase64String(ss.StringReverse(packageDecode[1]));
                    }

                    if (action.Equals("UPDATE"))
                    {
                        userId     = ss.DecodeBase64String(ss.StringReverse(packageDecode[0]));
                        verifyCode = ss.DecodeBase64String(ss.StringReverse(packageDecode[1]));

                        if (packageDecode.GetLength(0).Equals(4))
                        {
                            username = ss.DecodeBase64String(ss.StringReverse(packageDecode[2]));
                            password = ss.DecodeBase64String(ss.StringReverse(packageDecode[3]));
                        }
                    }

                    ds = iUtil.ExecuteCommandStoredProcedure(iUtil.bermudaConnectionString, "sp_sexSetUser",
                                                             new SqlParameter("@action", action),
                                                             new SqlParameter("@id", userId),
                                                             new SqlParameter("@username", username),
                                                             new SqlParameter("@password", password),
                                                             new SqlParameter("@verifyCode", verifyCode),
                                                             new SqlParameter("@verifyStatus", d.verifyStatus),
                                                             new SqlParameter("@titlePrefixId", d.titlePrefixId),
                                                             new SqlParameter("@firstName", d.firstName),
                                                             new SqlParameter("@middleName", d.middleName),
                                                             new SqlParameter("@lastName", d.lastName),
                                                             new SqlParameter("@nationalityId", d.nationalityId),
                                                             new SqlParameter("@genderId", d.genderId),
                                                             new SqlParameter("@email", d.email),
                                                             new SqlParameter("@countryId", d.countryId),
                                                             new SqlParameter("@cancelledStatus", d.cancelledStatus),
                                                             new SqlParameter("@by", d.by),
                                                             new SqlParameter("@ip", iUtil.GetIP())
                                                             );
                }
                catch
                {
                }
            }

            return(ds);
        }
        public void TestDoSave()
        {
            try
            {
                List<Student> test = new List<Student>();

                test.Add(new Student
                {
                    StudentName = "StudentName1",
                    StudentID = "S00001",
                    BirthDate = DateTime.Parse("#01/01/2000#"),
                    BirthPlace = "Denpasar",
                    Class = "Class1",
                    School = "ST. Yosef",
                    SexType = Student.Sex.Female,
                    RowAction = RowActions.New
                });

                test.Add(new Student
                {
                    StudentName = "StudentName2",
                    StudentID = "S00002",
                    BirthDate = DateTime.Parse("#01/02/2002#"),
                    BirthPlace = "Denpasar",
                    Class = "Class3",
                    School = "ST. Yosef",
                    SexType = Student.Sex.Male,
                    RowAction = RowActions.New
                });

                test.Add(new Student
                {
                    StudentName = "StudentName3",
                    StudentID = "S00003",
                    BirthDate = DateTime.Parse("#01/03/2001#"),
                    BirthPlace = "Yogyakarta",
                    Class = "Class2",
                    School = "ST. Yosef",
                    SexType = Student.Sex.Female,
                    RowAction = RowActions.New
                });

                test.Add(new Student
                {
                    StudentName = "StudentName4",
                    StudentID = "S00004",
                    BirthDate = DateTime.Parse("#04/01/2002#"),
                    BirthPlace = "Boston",
                    Class = "Class2",
                    School = "ST. Yosef",
                    SexType = Student.Sex.Male,
                    RowAction = RowActions.New
                });

                StudentService.StudentService service = new StudentService.StudentService();
                List<Student> result = service.DoSave(test);

                Assert.IsFalse(service.Errors.IsError(),  "There is unexpected error: " + string.Join(Environment.NewLine, service.Errors.Message.ToArray()));
                CollectionAssert.AreEquivalent(test, result, "result not equal");
            }

            finally
            {
                SetupEnvironment(mode.TearDown);
            }
        }
        public static DataSet SetData(string method, List <Application> data)
        {
            string action      = String.Empty;
            string cookieValue = String.Empty;

            string[] packageDecode = null;
            string   applicationId = String.Empty;
            string   userId        = String.Empty;
            string   verifyCode    = String.Empty;
            DataSet  ds            = new DataSet();

            StudentService.StudentService ss = new StudentService.StudentService();

            if (method.Equals("POST"))
            {
                action = "INSERT";
            }
            if (method.Equals("PUT"))
            {
                action = "UPDATE";
            }
            if (method.Equals("DELETE"))
            {
                action = "DELETE";
            }

            foreach (var d in data)
            {
                try
                {
                    packageDecode = ss.DecodeBase64String(d.package).Split('.');

                    if (action.Equals("INSERT"))
                    {
                        userId     = ss.DecodeBase64String(ss.StringReverse(packageDecode[0]));
                        verifyCode = ss.DecodeBase64String(ss.StringReverse(packageDecode[1]));
                    }

                    if (action.Equals("UPDATE"))
                    {
                        cookieValue = ss.DecodeBase64String(ss.StringReverse(packageDecode[0]));

                        if (iUtil.CompareCookie(iUtil.cookieName, cookieValue))
                        {
                            applicationId = ss.DecodeBase64String(ss.StringReverse(packageDecode[1]));
                            userId        = ss.DecodeBase64String(ss.StringReverse(packageDecode[2]));
                            verifyCode    = ss.DecodeBase64String(ss.StringReverse(packageDecode[3]));
                        }
                    }

                    ds = iUtil.ExecuteCommandStoredProcedure(iUtil.bermudaConnectionString, "sp_sexSetApplication",
                                                             new SqlParameter("@action", action),
                                                             new SqlParameter("@id", applicationId),
                                                             new SqlParameter("@userId", userId),
                                                             new SqlParameter("@verifyCode", verifyCode),
                                                             new SqlParameter("@titlePrefixId", d.titlePrefixId),
                                                             new SqlParameter("@firstName", d.firstName),
                                                             new SqlParameter("@middleName", d.middleName),
                                                             new SqlParameter("@lastName", d.lastName),
                                                             new SqlParameter("@nationalityId", d.nationalityId),
                                                             new SqlParameter("@genderId", d.genderId),
                                                             new SqlParameter("@email", d.email),
                                                             new SqlParameter("@studentCategoryId", d.studentCategoryId),
                                                             new SqlParameter("@studentCategorySpecify", d.studentCategorySpecify),
                                                             new SqlParameter("@studentCategoryOther", d.studentCategoryOther),
                                                             new SqlParameter("@countryId", d.countryId),
                                                             new SqlParameter("@universityId", d.universityId),
                                                             new SqlParameter("@universityOther", d.universityOther),
                                                             new SqlParameter("@facultyId", d.facultyId),
                                                             new SqlParameter("@department", d.department),
                                                             new SqlParameter("@semesterDateStart", d.semesterDateStart),
                                                             new SqlParameter("@semesterDateEnd", d.semesterDateEnd),
                                                             new SqlParameter("@homeAddress", d.homeAddress),
                                                             new SqlParameter("@homeDistrict", d.homeDistrict),
                                                             new SqlParameter("@homeCity", d.homeCity),
                                                             new SqlParameter("@homeProvince", d.homeProvince),
                                                             new SqlParameter("@homePostalCode", d.homePostalCode),
                                                             new SqlParameter("@countryHomeId", d.countryHomeId),
                                                             new SqlParameter("@mailingAddress", d.mailingAddress),
                                                             new SqlParameter("@mailingDistrict", d.mailingDistrict),
                                                             new SqlParameter("@mailingCity", d.mailingCity),
                                                             new SqlParameter("@mailingProvince", d.mailingProvince),
                                                             new SqlParameter("@mailingPostalCode", d.mailingPostalCode),
                                                             new SqlParameter("@countryMailingId", d.countryMailingId),
                                                             new SqlParameter("@contactTel", d.contactTel),
                                                             new SqlParameter("@birthdate", d.birthdate),
                                                             new SqlParameter("@maritalStatusId", d.maritalStatusId),
                                                             new SqlParameter("@passportNumber", d.passportNumber),
                                                             new SqlParameter("@passportExpiryDate", d.passportExpiryDate),
                                                             new SqlParameter("@emergencyName", d.emergencyName),
                                                             new SqlParameter("@relationshipId", d.relationshipId),
                                                             new SqlParameter("@emergencyMailingAddress", d.emergencyMailingAddress),
                                                             new SqlParameter("@emergencyMailingDistrict", d.emergencyMailingDistrict),
                                                             new SqlParameter("@emergencyMailingCity", d.emergencyMailingCity),
                                                             new SqlParameter("@emergencyMailingProvince", d.emergencyMailingProvince),
                                                             new SqlParameter("@emergencyMailingPostalCode", d.emergencyMailingPostalCode),
                                                             new SqlParameter("@countryMailingEmergencyId", d.countryMailingEmergencyId),
                                                             new SqlParameter("@emergencyHomeTel", d.emergencyHomeTel),
                                                             new SqlParameter("@emergencyOfficeTel", d.emergencyOfficeTel),
                                                             new SqlParameter("@emergencyMobile", d.emergencyMobile),
                                                             new SqlParameter("@emergencyFax", d.emergencyFax),
                                                             new SqlParameter("@emergencyEmail", d.emergencyEmail),
                                                             new SqlParameter("@curEduInstitution", d.curEduInstitution),
                                                             new SqlParameter("@curEduFaculty", d.curEduFaculty),
                                                             new SqlParameter("@disciplineId", d.disciplineId),
                                                             new SqlParameter("@educationalBackgroundId", d.educationalBackgroundId),
                                                             new SqlParameter("@curEduYear", d.curEduYear),
                                                             new SqlParameter("@TOEFLScore", d.TOEFLScore),
                                                             new SqlParameter("@TOEFLTypeId", d.TOEFLTypeId),
                                                             new SqlParameter("@IELTSResult", d.IELTSResult),
                                                             new SqlParameter("@englishNativeOther", d.englishNativeOther),
                                                             new SqlParameter("@passportFile", d.passportFile),
                                                             new SqlParameter("@facePhotographsFile", d.facePhotographsFile),
                                                             new SqlParameter("@transcriptFile", d.transcriptFile),
                                                             new SqlParameter("@travelInsuranceFile", d.travelInsuranceFile),
                                                             new SqlParameter("@letterHomeUniversityFile", d.letterHomeUniversityFile),
                                                             new SqlParameter("@curriculumVitaeFile", d.curriculumVitaeFile),
                                                             new SqlParameter("@TOEFLIELTSFile", d.TOEFLIELTSFile),
                                                             new SqlParameter("@letterIntentFile", d.letterIntentFile),
                                                             new SqlParameter("@declarationA", d.declarationA),
                                                             new SqlParameter("@declarationB", d.declarationB),
                                                             new SqlParameter("@declarationC", d.declarationC),
                                                             new SqlParameter("@declarationD", d.declarationD),
                                                             new SqlParameter("@declarationE", d.declarationE),
                                                             new SqlParameter("@declarationESpecify", d.declarationESpecify),
                                                             new SqlParameter("@submitStatus", d.submitStatus),
                                                             new SqlParameter("@submitBy", d.by),
                                                             new SqlParameter("@submitIp", iUtil.GetIP()),
                                                             new SqlParameter("@applicationStatus", d.applicationStatus),
                                                             new SqlParameter("@centralApprovalStatus", d.centralApprovalStatus),
                                                             new SqlParameter("@centralApprovalBy", d.by),
                                                             new SqlParameter("@centralApprovalIp", iUtil.GetIP()),
                                                             new SqlParameter("@divisionApprovalStatus", d.divisionApprovalStatus),
                                                             new SqlParameter("@divisionApprovalBy", d.by),
                                                             new SqlParameter("@divisionApprovalIp", iUtil.GetIP()),
                                                             new SqlParameter("@reason", d.reason),
                                                             new SqlParameter("@cancelledStatus", d.cancelledStatus),
                                                             new SqlParameter("@by", d.by),
                                                             new SqlParameter("@ip", iUtil.GetIP())
                                                             );
                }
                catch
                {
                }
            }

            return(ds);
        }