public JsonResult SaveApplicantRegistration(ApplicantRegistrationBO Data)
        {
            string strResult = "";

            if (Request.Files.Count > 0)
            {
                string strFileName       = "";
                string strExtention      = "";
                Random objRandom         = new Random();
                string strRandom         = objRandom.Next(10000) + "";
                string strFileUploadPath = "";

                string  fileName        = "";
                string  fileContentType = "";
                byte[]  tempFileBytes   = null;
                dynamic data            = null;
                dynamic types           = null;
                bool    result          = false;

                HttpFileCollectionBase files = Request.Files;
                if (files != null)
                {
                    for (int i = 0; i < files.Count; i++)
                    {
                        HttpPostedFileBase file = files[i];
                        if (file.ContentLength == 0)
                        {
                            strResult = "Upload file should not be empty";
                        }
                        else if (file.ContentLength > 0)
                        {
                            strExtention    = Path.GetExtension(file.FileName);
                            fileName        = file.FileName;                // getting File Name
                            fileContentType = file.ContentType;             // getting ContentType
                            tempFileBytes   = new byte[file.ContentLength]; // getting filebytes
                            data            = file.InputStream.Read(tempFileBytes, 0, Convert.ToInt32(file.ContentLength));
                            types           = CommonUtils.FileType.Image;   // Setting Image type
                            if (strExtention.ToUpper() == ".PDF")
                            {
                                types = CommonUtils.FileType.PDF;
                            }
                            else if (strExtention.ToUpper() == ".DOC")
                            {
                                types = CommonUtils.FileType.DOC;
                            }
                            else if (strExtention.ToUpper() == ".DOCX")
                            {
                                types = CommonUtils.FileType.DOCX;
                            }
                            result      = CommonUtils.isValidFile(tempFileBytes, types, fileContentType); // Validate Header
                            strFileName = strRandom + "_" + DateTime.UtcNow.ToString("yyyyMMddHHmmssfff", CultureInfo.InvariantCulture) + strExtention;
                            var strFileType = file.FileName.Split(new string[] { "_" }, StringSplitOptions.RemoveEmptyEntries);
                            if (result)
                            {
                                int FileLength = 1024 * 1024 * 3; //FileLength 3 MB
                                if (file.ContentLength > FileLength)
                                {
                                    strResult = "Upload file should not be greater than 3MB";
                                }

                                if (strFileType[0] == "PHOTO")
                                {
                                    Data.PhotoSavedName = strFileName;
                                    strFileUploadPath   = strPhotoUploadPath;
                                }
                                if (strFileType[0] == "RESUME")
                                {
                                    Data.CVSavedName  = strFileName;
                                    strFileUploadPath = strCVSavedUploadPath;
                                }
                                if (strFileType[0] == "IDCOPY")
                                {
                                    Data.CitizenShipIdCopySavedName = strFileName;
                                    strFileUploadPath = strCitizenShipIdCopyUploadPath;
                                }
                                if (strFileType[0] == "APPLICATIONLETTER")
                                {
                                    Data.ApplicationLetterSavedName = strFileName;
                                    strFileUploadPath = strApplicationLetterUploadPath;
                                }
                                //if (strFileType[0] == "BACHELORS")
                                //{
                                //    Data.BachelorsSavedName = strFileName;
                                //    strFileUploadPath = strBachelorsUploadPath;
                                //}
                                //if (strFileType[0] == "DIPLOMA")
                                //{
                                //    Data.DiplomaSavedName = strFileName;
                                //    strFileUploadPath = strDiplomaUploadPath;
                                //}
                                //if (strFileType[0] == "MSC")
                                //{
                                //    Data.MSCSavedName = strFileName;
                                //    strFileUploadPath = strMSCUploadPath;
                                //}
                                //if (strFileType[0] == "PHD")
                                //{
                                //    Data.PHDSavedName = strFileName;
                                //    strFileUploadPath = strPHDUploadPath;
                                //}
                                strFileName = Path.Combine(strFileUploadPath, strFileName);
                                file.SaveAs(strFileName);
                            }
                            else
                            {
                                strResult = strResult + "Please Upload Valid file for " + strFileType[0] + "</br>";
                            }
                        }
                    }
                }
            }
            ApplicantRegistrationBAL objApplicantRegistrationBAL = new ApplicantRegistrationBAL();

            Data.IsActive = true;
            string strReturnPassword = "";
            string strEmailBody      = "";

            if (Data.EmailAddress != "")
            {
                strEmailBody = getEmailBody((Data.FirstName + Data.LastName), Data.EmailAddress, ref strReturnPassword);
            }

            if (strResult == "")
            {
                strResult = objApplicantRegistrationBAL.SaveorUpdateApplicantRegistration(Data, strReturnPassword, 1);
                if (strResult == "SUCCESS" && Data.EmailAddress != "")
                {
                    strResult = CommonUtils.SendEmail(strSenderEmailAddress, Data.EmailAddress, strEmailSubject, strEmailBody);
                }
            }
            return(Json(strResult, JsonRequestBehavior.AllowGet));
        }
        public JsonResult SaveApplicantRegistration(ApplicantRegistrationBO Data)
        {
            if (Request.Files.Count > 0)
            {
                string strFileName           = "";
                string strExtention          = "";
                Random objRandom             = new Random();
                string strRandom             = objRandom.Next(1000000) + "";
                string strFileUploadPath     = "";
                HttpFileCollectionBase files = Request.Files;
                for (int i = 0; i < files.Count; i++)
                {
                    HttpPostedFileBase file = files[i];
                    strExtention = Path.GetExtension(file.FileName);
                    strFileName  = strRandom + DateTime.UtcNow.ToString("yyyyMMddHHmmssfff", CultureInfo.InvariantCulture) + strExtention;
                    var strFileType = file.FileName.Split(new string[] { "_" }, StringSplitOptions.RemoveEmptyEntries);
                    if (strFileType[0] == "PHOTO")
                    {
                        Data.PhotoSavedName = strFileName;
                        strFileUploadPath   = strPhotoUploadPath;
                    }
                    if (strFileType[0] == "RESUME")
                    {
                        Data.ResumSavedName = strFileName;
                        strFileUploadPath   = strCVSavedUploadPath;
                    }
                    if (strFileType[0] == "CITIZENSHIPIDCOPY")
                    {
                        Data.CitizenShipIdCopySavedName = strFileName;
                        strFileUploadPath = strCitizenShipIdCopyUploadPath;
                    }
                    if (strFileType[0] == "APPLICATIONLETTER")
                    {
                        Data.ApplicationLetterSavedName = strFileName;
                        strFileUploadPath = strApplicationLetterUploadPath;
                    }
                    if (strFileType[0] == "BACHELORS")
                    {
                        Data.BachelorsSavedName = strFileName;
                        strFileUploadPath       = strBachelorsUploadPath;
                    }
                    if (strFileType[0] == "DIPLOMA")
                    {
                        Data.DiplomaSavedName = strFileName;
                        strFileUploadPath     = strDiplomaUploadPath;
                    }
                    if (strFileType[0] == "MSC")
                    {
                        Data.MSCSavedName = strFileName;
                        strFileUploadPath = strMSCUploadPath;
                    }
                    if (strFileType[0] == "PHD")
                    {
                        Data.PHDSavedName = strFileName;
                        strFileUploadPath = strPHDUploadPath;
                    }

                    strFileName = Path.Combine(strFileUploadPath, strFileName);
                    file.SaveAs(strFileName);
                }
            }

            ApplicantRegistrationBAL objApplicantRegistrationBAL = new ApplicantRegistrationBAL();

            Data.IsActive = true;
            string strResult         = "";
            string strReturnPassword = "";
            string strEmailBody      = "";

            if (Data.EmailAddress != "")
            {
                strEmailBody = getEmailBody((Data.FirstName + Data.LastName), Data.EmailAddress, ref strReturnPassword);
            }

            strResult = objApplicantRegistrationBAL.SaveorUpdateApplicantRegistration(Data, strReturnPassword, 1);
            if (strResult == "SUCCESS" && Data.EmailAddress != "")
            {
                strResult = CommonUtils.SendEmail(strSenderEmailAddress, Data.EmailAddress, strEmailSubject, strEmailBody);
            }
            return(Json(strResult, JsonRequestBehavior.AllowGet));
        }