Пример #1
0
        public bool userExist(UserSignupPage data)
        {
            AzureConnection db = new AzureConnection();
            var             v  = db.user_table.Where(a => a.email == data.email || a.username == data.username).FirstOrDefault();

            return(v != null);
        }
Пример #2
0
        public ActionResult Registeration(UserSignupPage data)
        {
            bool   Status  = false;
            string message = "";

            ViewData["phoneNumber"] = Session["phoneNumber"].ToString();
            try
            {
                var IsExist = userExist(data);
                if (IsExist)
                {
                    message = "Email or username already exists";
                }
                else
                {
                    AzureConnection db     = new AzureConnection();
                    user_table      tbdata = new user_table();
                    tbdata.firstname     = data.firstname;
                    tbdata.lastname      = data.lastname;
                    tbdata.username      = data.username;
                    tbdata.email         = data.email;
                    tbdata.phone         = Session["phoneNumber"].ToString();
                    tbdata.country       = Session["countryCode"].ToString();
                    tbdata.phoneVerified = false;
                    tbdata.kycVerified   = false;
                    tbdata.password      = data.password;
                    tbdata.emailVerified = false;
                    tbdata.qrkey         = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10);
                    tbdata.signup        = DateTime.UtcNow;
                    tbdata.listme        = false;
                    tbdata.qrScanned     = false;
                    tbdata.emailCode     = Guid.NewGuid();
                    SendVerificationLinkEmail(tbdata);
                    message = "Activate your email to complete your setup. We have sent activation link to your email: " + data.email;
                    Status  = true;
                    db.user_table.Add(tbdata);
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
            }
            ViewBag.Message = message;
            ViewBag.Status  = Status;
            return(View(data));
        }
Пример #3
0
        public JsonResult saveUserInfo(UserSignupPage data, HttpPostedFileBase file)
        {
            bool    Status  = false;
            string  message = "";
            JObject result  = new JObject();

            try
            {
                AzureConnection db = new AzureConnection();

                var IsExist = userExist(data);
                if (IsExist)
                {
                    message = "Already exist. If you have an account , please log in";
                }
                else
                {
                    user_table tbdata = new user_table();
                    if (file != null)
                    {
                        shufti_log id_log = new shufti_log();
                        id_log.time = DateTime.UtcNow;
                        var memStream = new MemoryStream();
                        file.InputStream.CopyTo(memStream);
                        byte[] imageBytes   = memStream.ToArray();
                        var    base64String = Convert.ToBase64String(imageBytes);
                        string reponse      = ApiHelper.KYCApi.verifyIDCard(base64String, data.firstname, data.lastname);
                        var    reponseData  = JObject.Parse(reponse);
                        if (reponseData["event"].ToString() == "verification.declined")
                        {
                            id_log.status          = "verification.declined";
                            id_log.declined_reason = reponseData["declined_reason"].ToString();
                            db.shufti_log.Add(id_log);
                            db.SaveChanges();
                            result["state"]   = false;
                            result["message"] = reponseData["declined_reason"];
                            return(Json(JsonConvert.SerializeObject(result), JsonRequestBehavior.AllowGet));
                        }
                        else if (reponseData["event"].ToString() == "verification.accepted")
                        {
                            string first_name = reponseData["verification_data"]["document"]["name"]["first_name"].ToString();
                            string last_name  = reponseData["verification_data"]["document"]["name"]["last_name"].ToString();
                            string birthday   = reponseData["verification_data"]["document"]["dob"].ToString();
                            id_log.status          = "verification.accepted";
                            id_log.first_name      = first_name;
                            id_log.last_name       = last_name;
                            id_log.birthday        = birthday;
                            id_log.document_number = reponseData["verification_data"]["document"]["document_number"].ToString();
                            id_log.expiry_date     = reponseData["verification_data"]["document"]["expiry_date"].ToString();
                            id_log.issue_date      = reponseData["verification_data"]["document"]["issue_date"].ToString();
                            db.shufti_log.Add(id_log);
                            db.SaveChanges();
                            var old_kyc = db.user_table.Where(a => a.firstname == first_name && a.lastname == last_name && a.kycVerified == true && a.birthday == birthday).FirstOrDefault();
                            if (old_kyc != null)
                            {
                                result["state"]   = false;
                                result["message"] = "Someone already used this document.";
                                return(Json(JsonConvert.SerializeObject(result), JsonRequestBehavior.AllowGet));
                            }

                            /*
                             * if (data.firstname.ToUpper() != first_name.ToUpper()||data.lastname.ToUpper() != last_name.ToUpper())
                             * {
                             *  result["state"] = false;
                             *  result["message"] = "Your info is not correct!";
                             *  return Json(JsonConvert.SerializeObject(result), JsonRequestBehavior.AllowGet);
                             * }*/
                            tbdata.birthday    = birthday;
                            tbdata.kycVerified = true;
                        }
                    }

                    tbdata.firstname     = data.firstname;
                    tbdata.lastname      = data.lastname;
                    tbdata.username      = data.username;
                    tbdata.email         = data.email;
                    tbdata.password      = data.password;
                    tbdata.emailVerified = false;
                    tbdata.phone         = Session["phoneNumber"].ToString();
                    tbdata.country       = Session["countryCode"].ToString();
                    tbdata.phoneVerified = false;
                    tbdata.kycVerified   = (file != null);
                    tbdata.qrkey         = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10);
                    tbdata.qrScanned     = false;
                    tbdata.signup        = DateTime.UtcNow;
                    tbdata.listme        = false;
                    tbdata.emailCode     = Guid.NewGuid();
                    SendVerificationLinkEmail(tbdata);
                    message = "Activate your email to complete your setup.We have sent activation link to your email: " + data.email;

                    Status = true;
                    db.user_table.Add(tbdata);
                    db.SaveChanges();
                    Session["email"]    = tbdata.email;
                    Session["username"] = tbdata.username;
                    Session["qrkey"]    = tbdata.qrkey;
                }
            }
            catch (Exception ex)
            {
                message = "Some error occured.Please try again";
            }
            result["state"]   = Status;
            result["message"] = message;
            return(Json(JsonConvert.SerializeObject(result), JsonRequestBehavior.AllowGet));
        }