Exemple #1
0
        private void ForgetBtnClick(object sender, RoutedEventArgs e)
        {
            if (accountText.Text == "" | emailText.Text == "")
            {
                DialogShow.ShowOkDialog("Warning", "Have item empty!");
                return;
            }

            AccountProcess account = new AccountProcess();

            (string password, string errorType) = account.SearchPassword(accountText.Text, emailText.Text);

            if (password != "")
            {
                DialogShow.ShowOkDialog("Your password", password);
            }
            else
            {
                switch (errorType)
                {
                case "NOACCOUNT":
                    DialogShow.ShowOkDialog("Warning", "Your account not found, please register.");
                    break;

                case "ERRORMATCH":
                    DialogShow.ShowOkDialog("Warning", "Your account is not registered by this email.");
                    break;

                default:
                    break;
                }
            }
        }
Exemple #2
0
        public IHttpActionResult Get()
        {
            var process = new AccountProcess(unitOfWork);

            Result result = process.Get(User.Identity.GetId(), User.Identity.GetRole());

            return(GetErrorResult(result) ?? Ok(result));
        }
Exemple #3
0
        public async Task <IHttpActionResult> Register(Register register)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var process = new AccountProcess(unitOfWork);

            Result result = await process.Register(register.Name, register.Email, register.Password, register.RoleType);

            return(GetErrorResult(result) ?? Ok(result));
        }
Exemple #4
0
        public IHttpActionResult Update(Profile profile)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var process = new AccountProcess(unitOfWork);

            Result result = process.Update(User.Identity.GetId(), User.Identity.GetRole(), profile.Latitude, profile.Longitude, profile.Range, profile.Motto);

            return(GetErrorResult(result) ?? Ok(result));
        }
        public AccountRegistry(Func <Guid, Task <Option <AccountState> > > loadAccount
                               , Func <Event, Task <Unit> > saveAndPublish)
        {
            this.loadAccount = loadAccount;

            this.agent = Agent.Start(AccountsCache.Empty, (AccountsCache cache, Msg msg) =>
                                     new Pattern <(AccountsCache, Option <AccountProcess>)>
            {
                (LookupMsg m) => (cache, cache.Lookup(m.Id)),

                (RegisterMsg m) => cache.Lookup(m.Id).Match(
                    Some: acc => (cache, Some(acc)),
                    None: () =>
                {
                    var account = new AccountProcess(m.AccountState, saveAndPublish);
                    return(cache.Add(m.Id, account), Some(account));
                })
            }
Exemple #6
0
        private void LoginBtnClick(object sender, RoutedEventArgs e)
        {
            AccountProcess account = new AccountProcess();

            if (accountText.Text == "" | passwordText.Password == "")
            {
                DialogShow.ShowOkDialog("warning", "Have item empty!");
                return;
            }
            else if (account.Login(accountText.Text, passwordText.Password))
            {
                this.Hide();
                OrderWindow a = new OrderWindow();
                a.ShowDialog();
                this.Close();
            }
            else
            {
                DialogShow.ShowOkDialog("Error", "Not match account or password");
            }
        }
        public AccountRegistry_Naive(Func <Guid, Task <Option <AccountState> > > loadAccount
                                     , Func <Event, Task <Unit> > saveAndPublish)
        {
            agent = Agent.Start(AccountsCache.Empty
                                , async(AccountsCache cache, Guid id) =>
            {
                AccountProcess account;
                if (cache.TryGetValue(id, out account))
                {
                    return(cache, Some(account));
                }

                var optAccount = await loadAccount(id);

                return(optAccount.Map(accState =>
                {
                    var process = new AccountProcess(accState, saveAndPublish);
                    return (cache.Add(id, process), Some(process));
                })
                       .GetOrElse(() => (cache, (Option <AccountProcess>)None)));
            });
        }
Exemple #8
0
        private void RegisterAccountBtnClick(object sender, RoutedEventArgs e)
        {
            Console.WriteLine(passwordText.Password);
            if (accountText.Text == "" | passwordText.Password == "" | passwordConfirmText.Password == "" | emailText.Text == "")
            {
                DialogShow.ShowOkDialog("warning", "Have item empty!");
                return;
            }
            else if (passwordText.Password != passwordConfirmText.Password)
            {
                DialogShow.ShowOkDialog("warning", "Password and Confirm Password not same!");
                return;
            }

            AccountProcess account = new AccountProcess();
            bool           result  = account.Register(accountText.Text, passwordText.Password, emailText.Text);

            if (result == false)
            {
                DialogShow.ShowOkDialog("warning", "Account has already exist!");
                return;
            }
        }
 public AccountController()
 {
     _AccountProcess = new AccountProcess(_DatabaseHelper);
 }
Exemple #10
0
 public AccountController()
 {
     _accountProcess = new AccountProcess();
 }