public ActionResult Register(string UserName, string PassWord, string RePassWord,
                                     string FirstName, string LastName, string PhoneNumber, string Email)
        {
            if (PassWord.Equals(RePassWord) && UserName != "" && PassWord != "")
            {
                AccountAction.AddAccount(UserName, PassWord, FirstName, LastName, PhoneNumber, Email);
                ViewBag.Message = "Register successfully";
                return(RedirectToAction("HomePage", "Book"));
            }
            else
            {
                ViewBag.Message = "failed";
            }

            return(View());
        }
示例#2
0
        public ActionResult Login(LoginViewModel model)
        {
            var account = new AccountAction();
            LoginResultModel result;
            var accountModel = new LoginModel
            {
                email        = model.email,
                passwordHash = BaseMethods.GetHashSha256(model.password)
            };

            try
            {
                result = account.LogIn(accountModel);
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", "Ошибка авторизации. " + ex.Message);
                return(View(model));
            }

            switch (result.loginResult)
            {
            case LoginResult.Success:
                try
                {
                    Session.Login(result.userId ?? 0);
                    return(Redirect(Url.Content("~/")));
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", "Ошибка авторизации. " + ex.Message);
                    return(View(model));
                }

            case LoginResult.WrongLoginOrPassword:
                ModelState.AddModelError("", "Неправильный логин или пароль");
                return(View(model));

            case LoginResult.EmailIsNotConfirmed:
                ModelState.AddModelError("", "Электронная почта не подтверждена. Вам была вслана ссылка для подтверждения на электронную почту " + model.email);
                return(View(model));

            default:     //unreacheable
                return(View(model));
            }
        }
        public void Run(PairSocket shim, object[] args, CancellationToken token)
        {
            if (args == null || args.Count() != 1)
            {
                throw new InvalidOperationException(
                          "Args were not correct, expected one argument");
            }

            AccountAction accountAction = JsonConvert.DeserializeObject <AccountAction>(args[0].ToString());


            while (!token.IsCancellationRequested)
            {
                //Message for this actor/shim handler is expected to be
                //Frame[0] : Command
                //Frame[1] : Payload
                //
                //Result back to actor is a simple echoing of the Payload, where
                //the payload is prefixed with "AMEND ACCOUNT"
                NetMQMessage msg = null;

                //this may throw NetMQException if we have disposed of the actor
                //end of the pipe, and the CancellationToken.IsCancellationRequested
                //did not get picked up this loop cycle
                msg = shim.ReceiveMessage();

                if (msg == null)
                {
                    break;
                }

                if (msg[0].ConvertToString() == "AMEND ACCOUNT")
                {
                    string  json    = msg[1].ConvertToString();
                    Account account = JsonConvert.DeserializeObject <Account>(json);
                    AmmendAccount(accountAction, account);
                    shim.Send(JsonConvert.SerializeObject(account));
                }
                else
                {
                    throw NetMQException.Create("Unexpected command",
                                                ErrorCode.EFAULT);
                }
            }
        }
示例#4
0
        private void ButtonCreateNewAccount_Click(object sender, System.EventArgs e)
        {
            if (Page.IsValid)
            {
                AccountAction action = new AccountAction(Context);
                action.Account = ucAccount.Account;

                try
                {
                    action.CreateNewAccount();
                    this.CurrentController.NextView = action.NextViewToDisplay;
                }
                catch (NPetshop.Presentation.Exceptions.LoginAlreadyExistsException)
                {
                    LiteralMessage.Text = "Login already exist.";
                }
            }
        }
示例#5
0
        public ActionResult Download(string type)
        {
            string fileContent;
            string outputFileName;

            if (string.Equals(type, "account", StringComparison.OrdinalIgnoreCase))
            {
                fileContent    = JsonConvert.SerializeObject(AccountAction.GetAllAccounts());
                outputFileName = "accounts.txt";
            }
            else //"vendor"
            {
                fileContent    = JsonConvert.SerializeObject(VendorAction.GetAllVendors());
                outputFileName = "vendor.txt";
            }
            byte[] data = Encoding.UTF8.GetBytes(fileContent);
            return(File(data, "text/plain", outputFileName));
        }
示例#6
0
        public void AccountActorJSONSendReceiveTests()
        {
            AccountShimHandler accountShimHandler = new AccountShimHandler();

            AccountAction accountAction = new AccountAction(TransactionType.Credit, 10);
            Account       account       = new Account(1, "Test Account", "11223", 0);

            Actor <object> accountActor = new Actor <object>(NetMQContext.Create(), accountShimHandler, null);

            accountActor.SendMore("AMEND ACCOUNT");
            accountActor.SendMore(JsonConvert.SerializeObject(accountAction));
            accountActor.Send(JsonConvert.SerializeObject(account));
            Account updatedAccount =
                JsonConvert.DeserializeObject <Account>(accountActor.ReceiveString());
            decimal expectedAccountBalance = 10.0m;

            Assert.AreEqual(expectedAccountBalance, updatedAccount.Balance);
            accountActor.Dispose();
        }
示例#7
0
        public ActionResult Registration(RegistrationViewModel model)
        {
            var account        = new AccountAction();
            var registerObject = new RegisterModel
            {
                email        = model.email,
                name         = model.name,
                passwordHash = BaseMethods.GetHashSha256(model.password),
                phoneNumber  = model.phoneNumber
            };
            UserIdResult result;

            try
            {
                result = account.Register(registerObject);
                if (result.userId <= 0)
                {
                    throw new InvalidOperationException();
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", "Ошибка регистрации пользователя. " + ex.Message);
                return(View(model));
            }

            try
            {
                account.SendConfirmEmail(new UserIdModel {
                    userId = result.userId
                });
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", "Ошибка отправки подтверждения пользователя. " + ex.Message);
                return(View(model));
            }
            var message = "На электронную почту " + model.email + " отправлено письмо для подтверждения регистрации";

            return(RedirectToAction("Info", "Home", new InfoModel {
                message = message, header = "Спасибо за регистрацию!", status = StatusMessage.Mail
            }));
        }
示例#8
0
        private void ButtonLogIn_Click(object sender, System.EventArgs e)
        {
            if (Page.IsValid)
            {
                AccountAction action = new AccountAction(Context);
                action.Account.Login    = TextBoxLogin.Text;
                action.Account.Password = TextBoxPassword.Text;

                action.TryToAuthenticate();

                if (action.Account != null)
                {
                    this.CurrentController.NextView = action.NextViewToDisplay;
                }
                else
                {
                    LiteralMessage.Text = "Invalid login or password.  SignIn failed.";
                }
            }
        }
示例#9
0
        public ActionResult Login(AccountLogin acc)
        {
            Account account = AccountAction.VerifyAccount(acc.UserName, acc.Password);

            if (account != null)
            {
                Session["UserName"] = account.UserName;
                Session["Role"]     = account.RoleID;
                Session["UserID"]   = account.ID;
                if ((int)Session["Role"] == 1)
                {
                    return(RedirectToAction("ListBook", "Admin"));
                }
                return(RedirectToAction("ShopGrid", "Book"));
            }
            else
            {
                return(RedirectToAction("Login"));
            }
        }
示例#10
0
 public ActionResult Register(string UserName, string PassWord, string RePassWord,
                              string FirstName, string LastName, string PhoneNumber, string Email)
 {
     try
     {
         if (Session["Account_UserName"] == null)
         {
             Session["Account_Role"] = 0;
         }
         if (PassWord.Equals(RePassWord))
         {
             AccountAction.AddAccount(UserName, PassWord, FirstName, LastName, PhoneNumber, Email);
             ViewBag.Message = "Register successfully";
         }
         return(View());
     }
     catch
     {
         ViewBag.Message = "Register failed";
         return(View());
     }
 }
示例#11
0
        public ActionResult EmailConfrimation(string token)
        {
            var account   = new AccountAction();
            var tokenGuid = Guid.Empty;

            try
            {
                tokenGuid = new Guid(token);
            }
            catch
            {
                var message = "Неверный проверочный код! Электронная почта не подтверждена";
                return(RedirectToAction("Info", "Home", new InfoModel {
                    message = message, header = "Ошибка!", status = StatusMessage.Error
                }));
            }
            try
            {
                var result = account.ConfirmEmail(new TokenModel {
                    token = tokenGuid
                });
                if (result.userId <= 0)
                {
                    throw new ArgumentException();
                }
                Session.Login(result.userId);
                var message = "Электронная почта успешно подтверждена";
                return(RedirectToAction("Info", "Home", new InfoModel {
                    message = message, header = "Вы авторизованы!", status = StatusMessage.Accept
                }));
            }
            catch
            {
                var message = "Неверный проверочный код! Электронная почта не подтверждена";
                return(RedirectToAction("Info", "Home", new InfoModel {
                    message = message, header = "Ошибка!", status = StatusMessage.Error
                }));
            }
        }
示例#12
0
        private void AddJournalEntry(AccountAction accountAction)
        {
            var journalEntries = (JournalEntries)SapDiConnection.Instance.GetBusinessObject(BoObjectTypes.oJournalEntries);

            journalEntries.DueDate       = accountAction.RunDate;
            journalEntries.TaxDate       = accountAction.RunDate;
            journalEntries.ReferenceDate = accountAction.RunDate;
            journalEntries.VatDate       = accountAction.RunDate;
            journalEntries.StornoDate    = accountAction.RunDate;

            journalEntries.Lines.AccountCode = ((int)accountAction.FromAccount).ToString();
            journalEntries.Lines.Debit       = accountAction.Amount;
            // journalEntries.Lines.FCCurrency = accountAction.Currency;
            journalEntries.Lines.Add();

            journalEntries.Lines.AccountCode = ((int)accountAction.ToAccount).ToString();
            journalEntries.Lines.Credit      = accountAction.Amount;
            // journalEntries.Lines.FCCurrency = accountAction.Currency;
            journalEntries.Lines.Add();

            journalEntries.Add();
        }
        public void TestLogin_NotConfirmed()
        {
            var model = new RegisterModel
            {
                email        = "*****@*****.**" + Guid.NewGuid(),
                passwordHash = GetHashSha256("test" + Guid.NewGuid()),
                phoneNumber  = "79041840611"
            };
            var loginModel = new LoginModel
            {
                email        = model.email,
                passwordHash = model.passwordHash
            };

            new AccountAction().Register(model);
            //   var result = new AccountAction().Register(model);
            // TODO: Add your test code here
            var result = new AccountAction().LogIn(loginModel);

            // TODO: Add your test code here
            Assert.IsTrue(result.userId > 0 && result.loginResult == LoginResult.EmailIsNotConfirmed);
        }
示例#14
0
        public static bool permissionMenu(string menu)
        {
            AccountAction accountAction = new AccountAction();

            CIMS.BaseLayer.ActionResult actionResult = new CIMS.BaseLayer.ActionResult();

            string userRoles = "";

            actionResult = accountAction.Customer_LoadById();
            if (actionResult.IsSuccess)
            {
                DataRow  dr         = actionResult.dtResult.Rows[0];
                var      menuNames  = userRoles = dr["MenuNames"] != DBNull.Value ? dr["MenuNames"].ToString() : "";
                string[] blankArray = { };
                var      menuArray  = (menuNames != null? menuNames.Split(','):blankArray);
                if (menuArray.Contains(menu))
                {
                    return(true);
                }
            }

            return(false);
        }
示例#15
0
        public override void Parse(UserClient user, byte moduleCode, byte operationCode, OperationRequest operationRequest, SendParameters sendParameters)
        {
            //获取用户名和密码
            string username = operationRequest.Parameters[(byte)1].ToString();
            string userpwd  = operationRequest.Parameters[(byte)2].ToString();

            AccountAction aa = new AccountAction();

            Account ac = aa.CheckLogin(username, userpwd);


            //构建消息
            S2CMessage msg = new S2CMessage((byte)Module.Login, (byte)LoginOperation.UserLogin);

            Global.Info("向客户端发送信息" + msg.moudleCode + "," + msg.operationCode);

            LoginResultVo lro = new LoginResultVo();


            //登录成功
            if (ac != null)
            {
                lro.result = 1;
                lro.info   = "登录成功";
            }
            else
            {
                lro.result = 0;
                lro.info   = "用户名或密码错误!";
            }
            msg.Add((byte)1, JsonMapper.ToJson(lro));

            //发送反馈
            OperationResponse response = new OperationResponse((byte)moduleCode, msg);

            user.SendOperationResponse(response, sendParameters);
        }
示例#16
0
        public ActionResult ChangePassword(string token)
        {
            var account   = new AccountAction();
            var tokenGuid = Guid.Empty;

            try
            {
                tokenGuid = new Guid(token);
            }
            catch
            {
                var message = "Неверный проверочный код!";
                return(RedirectToAction("Info", "Home", new InfoModel {
                    message = message, header = "Ошибка!", status = StatusMessage.Error
                }));
            }

            var model = new ChangePasswordViewModel
            {
                token = tokenGuid
            };

            return(View(model));
        }
示例#17
0
 public ActionResult UndeleteMember(string ID)
 {
     MemberAction.Restore_Member(ID);
     AccountAction.Restore_Account(ID);
     return(Redirect("~/Account/AccountRestore"));
 }
示例#18
0
 public ActionResult Register(string Username, string Password, string Role)
 {
     AccountAction.Create_Acccount(Username, Password, Role);
     return(Redirect("~/Account/AccountManager"));
 }
 public ActionResult ListAccount(string SearchString)
 {
     ViewBag.ListAccount = AccountAction.Search(SearchString);
     return(View());
 }
示例#20
0
 public ActionResult ResetPassword(string Username)
 {
     AccountAction.Change_Password(Username, "123456");
     return(Redirect("~/Account/AccountManager"));
 }
示例#21
0
 public ActionResult ChangePassword(string Username, string Password)
 {
     AccountAction.Change_Password(Username, Password);
     return(Redirect("~/Home/HomePage"));
 }
示例#22
0
 public ActionResult Edit(int ID)
 {
     ViewBag.Account = AccountAction.FindAccount(ID);
     return(View());
 }
示例#23
0
 /// <summary>
 /// Handles the account event.
 /// </summary>
 /// <param name="accountaction">The accountaction.</param>
 private void HandleAccountEvent(AccountAction accountaction) =>
 Portfolio.CashManager.Process(accountaction.AccountActionType, accountaction.CurrencyType,
                               accountaction.Balance);
示例#24
0
        public void ShouldThrowIfStatementBalanceIsNull(DateTime date, AccountAction action, IAmount amount)
        {
            Action sut = () => new Statement(date, action, amount, null);

            sut.Should().Throw <ArgumentNullException>();
        }
示例#25
0
 public JsonResult Validation_Password(string Username)
 {
     return(Json(AccountAction.Find(Username), JsonRequestBehavior.AllowGet));
 }
 public ActionResult Change(int ID, int RoleID)
 {
     ViewBag.Change = AccountAction.EditRole(ID, RoleID);
     return(RedirectToAction("ChangeRole", "AdminMax"));
 }
示例#27
0
 public ActionResult UnLock(int ID)
 {
     AccountAction.UnLock(ID);
     return(RedirectToAction("ListAccount", "Admin"));
 }
示例#28
0
    protected void btnCreateAccount_Click(object sender, EventArgs e)
    {
        Account     objAccount       = new Account();
        AccountType objAccountType   = new AccountType();
        string      confirmationCode = "";

        try
        {
            string emailAddress = txtLoginEmail.Text.Trim();
            if (!validateEmail(emailAddress))
            {
                return;
            }



            objAccount.FullName    = "";
            objAccount.LastName    = "";
            objAccount.CompanyName = "";
            objAccount.Address     = "";
            objAccount.PostCode    = "";
            objAccount.City        = "";


            objAccount.EmailAddress = txtLoginEmail.Text;
            State objState = new State();
            objState.StateId = "-1";
            objAccount.State = objState;

            objAccount.Country.CountryId = "US";
            objAccount.Telephone         = "";
            objAccount.Fax       = "";
            objAccount.Mobile    = "";
            objAccount.SalesCode = "";
            objAccount.VATNumber = "";
            objAccount.VATNumberStatus.VATNumberStatusId = VATNumberStatusLookup.PendingVerification;
            objAccount.Discount = 0;

            objAccount.Password = txtLoginPassword.Text;
            objAccount.AccountStatus.AccountStatusId = AccountStatusLookup.Confirmed;
            objAccount.AgreedTCYN        = true;
            objAccountType.AccountTypeId = (int)AccountTypeEnum.ComplementaryAccount;
            objAccount.AccountType       = objAccountType;


            objAccount = AccountAction.AddAccount(objAccount, "nocode");
            ctlNotifier.intResponseCode = objAccount.RespCode;
            ctlNotifier.strResponse     = objAccount.RespDesc;
        }
        catch (Exception ex)
        {
            ctlNotifier.intResponseCode = 1;
            ctlNotifier.strResponse     = "An error occured while creating Account." + ex.Message;
            EmailHelper.SendErrorEmail("An error occured while creating Account for " + txtLoginEmail.Text + ". Support has been notified.", ex);
        }



        if (ctlNotifier.intResponseCode == 0)
        {
            try
            {
                EmailHelper.SendNewAccountEmail(objAccount, confirmationCode);
            }
            catch (Exception ex)
            {
                EmailHelper.SendErrorEmail("An error occured while sending new account creation mail to " + objAccount.EmailAddress + ".", ex);
            }
            finally
            {
                Response.Redirect("Success.aspx");

                /*
                 * string sellerURL = ConfigurationManager.AppSettings["sellerURL"];
                 *
                 * // Navigate to the sellers area
                 * Response.Redirect(sellerURL);
                 */
            }
        }
    }
示例#29
0
        static void Main(string[] args)
        {
            //Round 1 : Should work fine
            EchoShimHandler echoShimHandler = new EchoShimHandler();

            Actor actor = new Actor(NetMQContext.Create(), echoShimHandler, new object[] { "Hello World" });

            actor.SendMore("ECHO");
            string actorMessage = "This is a string";

            actor.Send(actorMessage);
            var result = actor.ReceiveString();

            Console.WriteLine("ROUND1");
            Console.WriteLine("========================");
            string expectedEchoHandlerResult = string.Format("ECHO BACK : {0}", actorMessage);

            Console.WriteLine("ExpectedEchoHandlerResult: '{0}'\r\nGot : '{1}'\r\n",
                              expectedEchoHandlerResult, result);
            actor.Dispose();

            //Round 2 : Should NOT work, as we are now using Disposed actor
            try
            {
                Console.WriteLine("ROUND2");
                Console.WriteLine("========================");
                actor.SendMore("ECHO");
                actor.Send("This is a string");
                result = actor.ReceiveString();
            }
            catch (NetMQException nex)
            {
                Console.WriteLine("NetMQException : Actor has been disposed so this is expected\r\n");
            }


            //Round 3 : Should work fine
            echoShimHandler = new EchoShimHandler();

            actor = new Actor(NetMQContext.Create(), echoShimHandler, new object[] { "Hello World" });
            actor.SendMore("ECHO");
            actorMessage = "Another Go";
            actor.Send(actorMessage);
            result = actor.ReceiveString();
            Console.WriteLine("ROUND3");
            Console.WriteLine("========================");
            expectedEchoHandlerResult = string.Format("ECHO BACK : {0}", actorMessage);
            Console.WriteLine("ExpectedEchoHandlerResult: '{0}'\r\nGot : '{1}'\r\n",
                              expectedEchoHandlerResult, result);
            actor.Dispose();



            //Round 4 : Should work fine
            AccountShimHandler accountShimHandler = new AccountShimHandler();

            AccountAction accountAction = new AccountAction(TransactionType.Credit, 10);
            Account       account       = new Account(1, "Test Account", "11223", 0);

            Actor accountActor = new Actor(NetMQContext.Create(), accountShimHandler,
                                           new object[] { JsonConvert.SerializeObject(accountAction) });

            accountActor.SendMore("AMEND ACCOUNT");
            accountActor.Send(JsonConvert.SerializeObject(account));
            Account updatedAccount =
                JsonConvert.DeserializeObject <Account>(accountActor.ReceiveString());

            Console.WriteLine("ROUND4");
            Console.WriteLine("========================");
            decimal expectedAccountBalance = 10.0m;

            Console.WriteLine(
                "Exected Account Balance: '{0}'\r\nGot : '{1}'\r\n" +
                "Are Same Account Object : '{2}'\r\n",
                expectedAccountBalance, updatedAccount.Balance,
                ReferenceEquals(accountActor, updatedAccount));
            accountActor.Dispose();


            Console.ReadLine();
        }
 // GET: AdminMax
 public ActionResult Add()
 {
     ViewBag.ListAccount = AccountAction.ListAccount();
     //AccountAction.
     return(View());
 }