コード例 #1
0
ファイル: BLLSchoolUser.cs プロジェクト: khilje125/iDAS
        public decimal RegisterNewMerchantUser(ModelMerchantUser objModelMerchantUser)
        {
            decimal result            = 0;
            string  getActivationCode = DALUtility.GetEmailActivationCode();

            SqlParameter[] param = new SqlParameter[8];

            param[0] = new SqlParameter("@MerchantNameEN", objModelMerchantUser.MerchantNameEN);
            param[1] = new SqlParameter("@MerchantEmail", objModelMerchantUser.MerchantEmail);
            param[2] = new SqlParameter("@MerchantPassword", EncryptDecrypt.Encrypt(objModelMerchantUser.MerchantPassword));
            param[3] = new SqlParameter("@strAdminUserMobile", objModelMerchantUser.MerchantMobileNumber);
            param[4] = new SqlParameter("@CompanyNameEN", objModelMerchantUser.CompanyNameEN);
            param[5] = new SqlParameter("@sCompanyLogo", objModelMerchantUser.CompanyLogo);
            param[6] = new SqlParameter("@AccountStatus", 1);
            param[7] = new SqlParameter("@ActivationCodeByEmail", getActivationCode);

            result = DALCommon.ExecuteNonQueryReturnIdentity("[sp_Admin_InsertMerchantUser]", param);
            if (result > 0)
            {
                string MerchantKey         = EncryptDecrypt.Encrypt(DALUtility.GetEmailActivationCode());
                string MerchantReferenceID = EncryptDecrypt.GenerateHashCode(result + MerchantKey + System.DateTime.Now);
                if (UpdateMercharAPIKeys(result, MerchantKey, MerchantReferenceID) > 0)
                {
                    SendActivationCode(getActivationCode, objModelMerchantUser.MerchantEmail);
                }
            }
            return(result);
        }
コード例 #2
0
        public ActionResult Register(ModelMerchantUser objModelMerchantUser)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (objModelMerchantUser == null)
                    {
                        return(RedirectToAction("Login", "User"));
                    }
                    objBLLSchoolUser = new BLLSchoolUser();
                    StringBuilder st     = new StringBuilder();
                    decimal       result = 0;

                    foreach (string file in Request.Files)
                    {
                        HttpPostedFileBase hpf = Request.Files[file] as HttpPostedFileBase;
                        if (hpf.ContentLength == 0)
                        {
                            continue;
                        }

                        string savedFileName = Path.Combine(Server.MapPath("~/Content/MerchantLogo"), Path.GetFileName(hpf.FileName));
                        hpf.SaveAs(savedFileName); // Save the file
                        objModelMerchantUser.CompanyLogo = hpf.FileName;
                    }

                    result = objBLLSchoolUser.RegisterNewMerchantUser(objModelMerchantUser);
                    if (result > 0)
                    {
                        Success(string.Format("{0} was successfully registered", objModelMerchantUser.MerchantEmail));

                        return(RedirectToAction("Login", "User"));
                    }
                    else if (result == -2)
                    {
                        Attention(string.Format("{0} Email alraedy registered. Please use new Email Addess. If forgot password try to recover your account.", objModelMerchantUser.MerchantEmail));

                        return(RedirectToAction("Login", "User"));
                    }
                    else
                    {
                        Error(string.Format("Error occured while Registering {0}", objModelMerchantUser.MerchantEmail));
                        return(RedirectToAction("Register", "User", objModelMerchantUser));
                    }
                }
                catch (Exception ex)
                {
                    DALUtility.ErrorLog(ex.Message, "AddRegister, Merchant");
                }
            }
            else
            {
                Error("Check error of form; Please correct to continue!");
                //ModelState.AddModelError("", "Check error of form; Please correct to continue!");
            }
            return(RedirectToAction("Login", "User"));
        }