Exemplo n.º 1
0
        public ActionResult Details(KYCModel kycModel, HttpPostedFileBase PPImageFile, HttpPostedFileBase Id_DocumentFrontFile, HttpPostedFileBase Id_DocumentBackFile, string submitbutton, string OthersRemarks = "")
        {
            if (submitbutton.ToUpper() == "GOBACK")
            {
                return(RedirectToAction("Index", ControllerName));
            }
            LoadDropDownList(kycModel);
            #region FileLocation

            string FileLocation;
            string usertype = kycModel.AgentType;
            if (usertype.ToLower() == "distributor")
            {
                FileLocation = "/Content/userupload/Distributor/kyc/";
            }
            else if (usertype.ToLower() == "sub-distributor")
            {
                FileLocation = "/Content/userupload/SubDistributor/kyc/";
            }
            else if (usertype.ToLower() == "walletuser")
            {
                FileLocation = "/Content/userupload/Walletuser/kyc/";
            }
            else if (usertype.ToLower() == "merchant")
            {
                FileLocation = "/Content/userupload/Merchant/kyc/";
            }
            else if (usertype.ToLower() == "agent")
            {
                FileLocation = "/Content/userupload/Agent/kyc/";
            }
            else if (usertype.ToLower() == "sub-agent")
            {
                FileLocation = "/Content/userupload/SubAgent/kyc/";
            }
            else
            {
                FileLocation = "/Content/userupload/";
            }

            ViewBag.FileLocation = FileLocation;
            #endregion
            if (String.IsNullOrEmpty(kycModel.AgentId))
            {
                return(RedirectToAction("Index", ControllerName));
            }
            string status = "";
            if (submitbutton.ToUpper() == "REJECT")
            {
                status = "r";
                if (kycModel.Remarks.ToUpper().Equals("OTHERS"))
                {
                    if (OthersRemarks == "")
                    {
                        ModelState.AddModelError("OtherRemarks", "Other Remarks is Required");
                        return(View(kycModel));
                    }
                    else
                    {
                        kycModel.Remarks = "Others::" + OthersRemarks;
                    }
                }
                RejectValidation();
            }
            else if (submitbutton.ToUpper() == "APPROVE")
            {
                status = "a";
                ModelState.Remove(("Remarks"));
            }
            else if (submitbutton.ToUpper() == "UPDATE")
            {
                status = "u";
                ModelState.Remove(("Remarks"));
            }
            else
            {
                return(RedirectToAction("Index", ControllerName));
            }

            if (submitbutton.ToUpper() != "REJECT")
            {
                if ((Id_DocumentFrontFile == null && string.IsNullOrEmpty(kycModel.Id_DocumentFront)) ||
                    (PPImageFile == null && string.IsNullOrEmpty(kycModel.PPImage)) ||
                    (Id_DocumentBackFile == null && string.IsNullOrEmpty(kycModel.Id_DocumentBack) && kycModel.Id_type.ToUpper() == "CITIZENSHIP"))
                {
                    if (Id_DocumentFrontFile == null && string.IsNullOrEmpty(kycModel.Id_DocumentFront))
                    {
                        ModelState.AddModelError("Id_DocumentFront", "Document Front Image is Required");
                    }
                    if (PPImageFile == null && string.IsNullOrEmpty(kycModel.PPImage))
                    {
                        ModelState.AddModelError("PPImage", "Profile Image is Required");
                    }
                    if ((Id_DocumentBackFile == null && string.IsNullOrEmpty(kycModel.Id_DocumentBack) && kycModel.Id_type.ToUpper() == "CITIZENSHIP"))
                    {
                        ModelState.AddModelError("Id_DocumentBack", "Document Front Image is Required");
                    }
                    return(View(kycModel));
                }

                if (kycModel.Id_type.ToUpper() == "CITIZENSHIP")
                {
                    ModelState.Remove(("Id_ExpiryDateAD"));
                    ModelState.Remove(("Id_ExpiryDateBS"));
                }
                string temp_address = kycModel.SameAsPermanentAddress.ToString();
                if (temp_address == "True")
                {
                    kycModel.TProvince  = kycModel.PProvince;
                    kycModel.TDistrict  = kycModel.PDistrict;
                    kycModel.TLocalBody = kycModel.PLocalBody;
                    kycModel.TWardNo    = kycModel.PWardNo;
                    kycModel.TAddress   = kycModel.PAddress;
                }
            }

            string ID                   = "";
            var    PPImagePath          = "";
            var    Id_DocumentFrontPath = "";
            var    Id_DocumentBackPath  = "";

            if (ModelState.IsValid)
            {
                //kycModel.Remarks = String.IsNullOrEmpty(kycModel.Remarks) ? "" :
                //  kycModel.Remarks.ToUpper().Equals("OTHERS") ? OthersRemarks : kycModel.Remarks;

                kycModel.ActionUser = Session["UserName"].ToString();

                ID = kycModel.AgentId.DecryptParameter();
                kycModel.AgentId = ID;

                #region "PPImage"
                if (PPImageFile != null && (status.ToUpper() == "A" || status.ToUpper() == "U"))
                {
                    var    allowedExtensions = new[] { ".jpg", ".png", ".jpeg" };
                    var    fileName          = Path.GetFileName(PPImageFile.FileName);
                    String timeStamp         = DateTime.Now.ToString();
                    var    ext = Path.GetExtension(PPImageFile.FileName);
                    if (PPImageFile.ContentLength > 1 * 1024 * 1024)//1 MB
                    {
                        return(RedirectToAction("Details", ControllerName, ID));
                    }
                    if (allowedExtensions.Contains(ext.ToLower()))
                    {
                        string datet      = timeStamp.Replace('/', ' ').Replace(':', ' ');
                        string myfilename = kycModel.MobileNo + "-PPImage-" + datet + ext;
                        PPImagePath      = Path.Combine(Server.MapPath(FileLocation), myfilename);
                        kycModel.PPImage = FileLocation + myfilename;
                        //PPImageFile.SaveAs(PPImagePath);
                    }
                    else
                    {
                        return(RedirectToAction("Details", ControllerName, ID));
                    }
                }
                #endregion
                #region "Id_DocumentFront"
                if (Id_DocumentFrontFile != null && (status.ToUpper() == "A" || status.ToUpper() == "U"))
                {
                    var    allowedExtensions = new[] { ".jpg", ".png", ".jpeg" };
                    var    fileName          = Path.GetFileName(Id_DocumentFrontFile.FileName);
                    String timeStamp         = DateTime.Now.ToString();
                    var    ext = Path.GetExtension(Id_DocumentFrontFile.FileName);
                    if (Id_DocumentFrontFile.ContentLength > 1 * 1024 * 1024)//1 MB
                    {
                        return(RedirectToAction("Details", ControllerName, ID));
                    }
                    if (allowedExtensions.Contains(ext.ToLower()))
                    {
                        string datet      = timeStamp.Replace('/', ' ').Replace(':', ' ');
                        string myfilename = kycModel.MobileNo + "-Id_DocumentFront-" + datet + ext;
                        Id_DocumentFrontPath      = Path.Combine(Server.MapPath(FileLocation), myfilename);
                        kycModel.Id_DocumentFront = FileLocation + myfilename;
                        //Id_DocumentFrontFile.SaveAs(Id_DocumentFrontPath);
                    }
                    else
                    {
                        return(RedirectToAction("Details", ControllerName, ID));
                    }
                }
                #endregion
                #region "Id_DocumentBack"
                if (Id_DocumentBackFile != null && (status.ToUpper() == "A" || status.ToUpper() == "U"))
                {
                    var    allowedExtensions = new[] { ".jpg", ".png", ".jpeg" };
                    var    fileName          = Path.GetFileName(Id_DocumentBackFile.FileName);
                    String timeStamp         = DateTime.Now.ToString();
                    var    ext = Path.GetExtension(Id_DocumentBackFile.FileName);
                    if (Id_DocumentBackFile.ContentLength > 1 * 1024 * 1024)//1 MB
                    {
                        return(RedirectToAction("Details", ControllerName, ID));
                    }
                    if (allowedExtensions.Contains(ext.ToLower()))
                    {
                        string datet      = timeStamp.Replace('/', ' ').Replace(':', ' ');
                        string myfilename = kycModel.MobileNo + "-Id_DocumentBack-" + datet + ext;
                        Id_DocumentBackPath      = Path.Combine(Server.MapPath(FileLocation), myfilename);
                        kycModel.Id_DocumentBack = FileLocation + myfilename;
                        //Id_DocumentBackFile.SaveAs(Id_DocumentBackPath);
                    }
                    else
                    {
                        return(RedirectToAction("Details", ControllerName, ID));
                    }
                }
                #endregion
                KYCCommon        kycCommon  = kycModel.MapObject <KYCCommon>();
                CommonDbResponse dbResponse = _kyc.UpadateKycDetails(kycCommon, status);
                if (dbResponse.Code == 0)
                {
                    //SaveImages On Success
                    if (PPImagePath != "")
                    {
                        PPImageFile.SaveAs(PPImagePath);
                    }
                    if (Id_DocumentFrontPath != "")
                    {
                        Id_DocumentFrontFile.SaveAs(Id_DocumentFrontPath);
                    }
                    if (Id_DocumentBackPath != "")
                    {
                        Id_DocumentBackFile.SaveAs(Id_DocumentBackPath);
                    }
                    //Ends SaveImages
                }
                dbResponse.SetMessageInTempData(this);
                return(RedirectToAction("Index"));
            }

            return(View(kycModel));
            //return RedirectToAction("Index");
        }
Exemplo n.º 2
0
        public ActionResult Kyc(KYCModel clientkyc, HttpPostedFileBase PPImageFile, HttpPostedFileBase Id_DocumentFrontFile, HttpPostedFileBase Id_DocumentBackFile)
        {
            LoadDropDownList(clientkyc);
            string status = "u";

            ModelState.Remove(("Remarks"));
            #region FileLocation

            string FileLocation;
            string usertype = Session["UserType"].ToString();
            if (usertype.ToLower() == "distributor")
            {
                FileLocation = "/Content/userupload/Distributor/kyc/";
            }
            else if (usertype.ToLower() == "sub-distributor")
            {
                FileLocation = "/Content/userupload/SubDistributor/kyc/";
            }
            else if (usertype.ToLower() == "walletuser")
            {
                FileLocation = "/Content/userupload/Walletuser/kyc/";
            }
            else if (usertype.ToLower() == "merchant")
            {
                FileLocation = "/Content/userupload/Merchant/kyc/";
            }
            else if (usertype.ToLower() == "agent")
            {
                FileLocation = "/Content/userupload/Agent/kyc/";
            }
            else if (usertype.ToLower() == "sub-agent")
            {
                FileLocation = "/Content/userupload/SubAgent/kyc/";
            }
            else
            {
                FileLocation = "/Content/userupload/";
            }

            ViewBag.FileLocation = FileLocation;
            #endregion

            if ((Id_DocumentFrontFile == null && string.IsNullOrEmpty(clientkyc.Id_DocumentFront)) ||
                (PPImageFile == null && string.IsNullOrEmpty(clientkyc.PPImage)) ||
                (Id_DocumentBackFile == null && string.IsNullOrEmpty(clientkyc.Id_DocumentBack) && clientkyc.Id_type.ToUpper() == "CITIZENSHIP"))
            {
                if (Id_DocumentFrontFile == null && string.IsNullOrEmpty(clientkyc.Id_DocumentFront))
                {
                    ModelState.AddModelError("Id_DocumentFront", "Document Front Image is Required");
                }
                if (PPImageFile == null && string.IsNullOrEmpty(clientkyc.PPImage))
                {
                    ModelState.AddModelError("PPImage", "Profile Image is Required");
                }
                if ((Id_DocumentBackFile == null && string.IsNullOrEmpty(clientkyc.Id_DocumentBack) && clientkyc.Id_type.ToUpper() == "CITIZENSHIP"))
                {
                    ModelState.AddModelError("Id_DocumentBack", "Document Front Image is Required");
                }
                return(View(clientkyc));
            }

            if (clientkyc.Id_type.ToUpper() == "CITIZENSHIP")
            {
                //if (Id_DocumentBackFile == null && string.IsNullOrEmpty(clientkyc.Id_DocumentBack))
                //{
                //    ModelState.AddModelError("Id_DocumentBack", "Document Front Image is Required");
                //    return View(clientkyc);
                //}
                ModelState.Remove(("Id_ExpiryDateAD"));
                ModelState.Remove(("Id_ExpiryDateBS"));
            }

            var PPImagePath          = "";
            var Id_DocumentFrontPath = "";
            var Id_DocumentBackPath  = "";

            string temp_address = clientkyc.SameAsPermanentAddress.ToString();
            if (temp_address == "True")
            {
                clientkyc.TProvince  = clientkyc.PProvince;
                clientkyc.TDistrict  = clientkyc.PDistrict;
                clientkyc.TLocalBody = clientkyc.PLocalBody;
                clientkyc.TWardNo    = clientkyc.PWardNo;
                clientkyc.TAddress   = clientkyc.PAddress;
            }

            if (ModelState.IsValid)
            {
                //clientkyc.Remarks = String.IsNullOrEmpty(clientkyc.Remarks) ? "" :
                //  clientkyc.Remarks.ToUpper().Equals("OTHERS") ? OthersRemarks : clientkyc.Remarks;

                clientkyc.ActionUser = Session["UserName"].ToString();

                #region "PPImage"
                if (PPImageFile != null && status.ToUpper() == "U")
                {
                    var    allowedExtensions = new[] { ".jpg", ".png", ".jpeg" };
                    var    fileName          = Path.GetFileName(PPImageFile.FileName);
                    String timeStamp         = DateTime.Now.ToString();
                    var    ext = Path.GetExtension(PPImageFile.FileName);
                    if (PPImageFile.ContentLength > 1 * 1024 * 1024)//1 MB
                    {
                        return(RedirectToAction("Kyc", ControllerName));
                    }
                    if (allowedExtensions.Contains(ext.ToLower()))
                    {
                        string datet      = timeStamp.Replace('/', '-').Replace(':', '-');
                        string myfilename = clientkyc.MobileNo + "-PPImage-" + datet + ext;
                        PPImagePath       = Path.Combine(Server.MapPath(FileLocation), myfilename);
                        clientkyc.PPImage = FileLocation + myfilename;
                        //PPImageFile.SaveAs(PPImagePath);
                    }
                    else
                    {
                        return(RedirectToAction("Kyc", ControllerName));
                    }
                }
                #endregion
                #region "Id_DocumentFront"
                if (Id_DocumentFrontFile != null && status.ToUpper() == "U")
                {
                    var    allowedExtensions = new[] { ".jpg", ".png", ".jpeg" };
                    var    fileName          = Path.GetFileName(Id_DocumentFrontFile.FileName);
                    String timeStamp         = DateTime.Now.ToString();
                    var    ext = Path.GetExtension(Id_DocumentFrontFile.FileName);
                    if (Id_DocumentFrontFile.ContentLength > 1 * 1024 * 1024)//1 MB
                    {
                        return(RedirectToAction("Kyc", ControllerName));
                    }
                    if (allowedExtensions.Contains(ext.ToLower()))
                    {
                        string datet      = timeStamp.Replace('/', '-').Replace(':', '-');
                        string myfilename = clientkyc.MobileNo + "-Id_DocumentFront-" + datet + ext;
                        Id_DocumentFrontPath       = Path.Combine(Server.MapPath(FileLocation), myfilename);
                        clientkyc.Id_DocumentFront = FileLocation + myfilename;
                        //Id_DocumentFrontFile.SaveAs(Id_DocumentFrontPath);
                    }
                    else
                    {
                        return(RedirectToAction("Kyc", ControllerName));
                    }
                }
                #endregion
                #region "Id_DocumentBack"
                if (Id_DocumentBackFile != null && status.ToUpper() == "U")
                {
                    var    allowedExtensions = new[] { ".jpg", ".png", ".jpeg" };
                    var    fileName          = Path.GetFileName(Id_DocumentBackFile.FileName);
                    String timeStamp         = DateTime.Now.ToString();
                    var    ext = Path.GetExtension(Id_DocumentBackFile.FileName);
                    if (Id_DocumentBackFile.ContentLength > 1 * 1024 * 1024)//1 MB
                    {
                        return(RedirectToAction("Kyc", ControllerName));
                    }
                    if (allowedExtensions.Contains(ext.ToLower()))
                    {
                        string datet      = timeStamp.Replace('/', '-').Replace(':', '-');
                        string myfilename = clientkyc.MobileNo + "-Id_DocumentBack-" + datet + ext;
                        Id_DocumentBackPath       = Path.Combine(Server.MapPath(FileLocation), myfilename);
                        clientkyc.Id_DocumentBack = FileLocation + myfilename;
                        //Id_DocumentBackFile.SaveAs(Id_DocumentBackPath);
                    }
                    else
                    {
                        return(RedirectToAction("Kyc", ControllerName));
                    }
                }
                #endregion
                KYCCommon        kycCommon  = clientkyc.MapObject <KYCCommon>();
                CommonDbResponse dbResponse = _kyc.UpadateKycDetails(kycCommon, status);
                if (dbResponse.Code == 0)
                {
                    //SaveImages On Success
                    if (PPImagePath != "")
                    {
                        PPImageFile.SaveAs(PPImagePath);
                    }
                    if (Id_DocumentFrontPath != "")
                    {
                        Id_DocumentFrontFile.SaveAs(Id_DocumentFrontPath);
                    }
                    if (Id_DocumentBackPath != "")
                    {
                        Id_DocumentBackFile.SaveAs(Id_DocumentBackPath);
                    }
                    //Ends SaveImages
                }
                dbResponse.SetMessageInTempData(this);
                return(RedirectToAction("Profile"));
            }
            return(View(clientkyc));
        }