Пример #1
0
        static void Main(string [] args)
        {  //early Binding
           //PayIncomeTax();

            // late Binding

            AccountHandler operation1 = null;

            operation1 = new AccountHandler(PayIncomeTax);  //registering name of function to be invoked

            AccountHandler operation2 = null;

            operation2 = new AccountHandler(PayProfessionalTax);

            AccountHandler operation3 = null;

            operation3 = new AccountHandler(PayServiceTax);   //unicast delegate


            AccountHandler masterOperationManager = null;

            masterOperationManager  = operation1;  //multicast
            masterOperationManager += operation2;
            masterOperationManager += operation3;

            masterOperationManager();  // one invokation  ///multicast delegate


            Console.WriteLine("after unregistration");
            masterOperationManager -= operation3;
            masterOperationManager();  // one invokation  ///multicast delegate

            Console.ReadLine();
        }
 /// <summary>
 /// Method that changes the password of the account and writes the account list to the file
 /// </summary>
 public void ChangePassword()
 {
     AccountHandler.Account.PassWord = EnteredConfirmPassword;
     AccountHandler.ChangeUserPassword(EnteredConfirmPassword);
     AccountHandler.AccountList.AddAccountToFile();
     IsConfirmButtonEnabled = false;
 }
Пример #3
0
        /// <summary>
        /// Executes the plug-in.
        /// </summary>
        /// <param name="localContext">The <see cref="LocalPluginContext"/> which contains the
        /// <see cref="IPluginExecutionContext"/>,
        /// <see cref="IOrganizationService"/>
        /// and <see cref="ITracingService"/>
        /// </param>
        /// <remarks>
        /// For improved performance, Microsoft Dynamics CRM caches plug-in instances.
        /// The plug-in's Execute method should be written to be stateless as the constructor
        /// is not called for every invocation of the plug-in. Also, multiple system threads
        /// could execute the plug-in at the same time. All per invocation state information
        /// is stored in the context. This means that you should not use global variables in plug-ins.
        /// </remarks>
        protected void ExecutePostAccountCreate(LocalPluginContext localContext)
        {
            if (localContext == null)
            {
                throw new ArgumentNullException("localContext");
            }

            IPluginExecutionContext context = localContext.PluginExecutionContext;
            IOrganizationService    service = localContext.OrganizationService;
            ITracingService         trace   = localContext.TracingService;
            Entity accountEntity            = (Entity)context.InputParameters["Target"];

            string message = context.MessageName;
            string error   = "";

            try
            {
                AccountHandler accountHandler = new AccountHandler(service, trace);
                accountHandler.SetCity(accountEntity);
                accountHandler.ValidatePrimaryContact(accountEntity);
                accountHandler.PopulateDealerCode(accountEntity);
                accountHandler.PopulateTaxRate(accountEntity);
                accountHandler.PopulateWithholdingTaxRate(accountEntity, "gsc_partswithholdingtaxid", "gsc_partswithholdingtaxrate");
                accountHandler.PopulateWithholdingTaxRate(accountEntity, "gsc_vehiclewithholdingtaxid", "gsc_vehiclewithholdingtaxrate");
                accountHandler.ReplicateAddresstoBillingAddress(accountEntity);
                accountHandler.PopulatePrimaryContactDetails(accountEntity);
            }
            catch (Exception ex)
            {
                //throw new InvalidPluginExecutionException(String.Concat("(Exception)\n", ex.Message, Environment.NewLine, ex.StackTrace, Environment.NewLine, error));
                throw new InvalidPluginExecutionException(ex.Message);
            }
        }
Пример #4
0
        /// <summary>
        /// Tjekker om der eksistere en bruger med given mail og opretter en ny bruger hvis det ikke er tilfældet
        /// </summary>
        public async void Opret()
        {
            AccountObj.Name        = Name;
            AccountObj.Email       = ID;
            AccountObj.Password    = Password;
            AccountObj.AccountType = "U";

            Account       userAccount = new AccountHandler().ReadFrom(ID);
            ContentDialog dialog      = new ContentDialog()
            {
                CloseButtonText = "Ok"
            };

            if (userAccount == null)
            {
                new AccountHandler().Create(AccountObj);

                dialog.Content = $"Bruger med Email: {ID} er nu Oprettet! Du kan nu logge ind med din bruger.";
            }
            else
            {
                dialog.Content = $"Bruger med given email: {ID} eksistere allerede";
            }

            dialog.ShowAsync();
        }
Пример #5
0
        public ActionResult ForgotPassword(string EmailID)
        {
            // generate reset code
            string resetCode = Guid.NewGuid().ToString();

            // define request
            AccountRequest request = new AccountRequest
            {
                Data = new AccountModel
                {
                    Email             = EmailID,
                    ResetPasswordCode = resetCode
                }
            };

            // set reset password code
            var response = new AccountHandler(_unitOfWork, _context).SetResetPasswordCode(request);

            if (response.Status)
            {
                // send verification email
                SendVerificationLinkEmail(EmailID, resetCode);

                ViewBag.Message = Messages.ResetPasswordLinkSent;
            }
            else
            {
                ViewBag.Message = string.Format(Messages.EmployeeWithEmailNotExist, EmailID);
            }

            return(View());
        }
 public AccountHandlerTests()
 {
     _repository     = new AccountRepository();
     _tokenService   = new TokenService();
     _accountHandler = new AccountHandler(_repository, _tokenService);
     _command        = new AccountLoginCommand("*****@*****.**", "password");
 }
        public void Deposit_CantDepositwNegativeAmounts()
        {
            using (var context = new BankAppDataContext(_options))
            {
                // Arrange
                int accountId = 78901;

                Account temporaryAccount = new Account();
                temporaryAccount.Balance   = 500.00m;
                temporaryAccount.AccountId = accountId;
                decimal expected = temporaryAccount.Balance;

                // Saving the account to DB
                context.Accounts.Add(temporaryAccount);
                context.SaveChanges();
                decimal amount = -800.00m;
                // Act & Assert
                Action act = () =>
                {
                    bool actual = new AccountHandler().Deposit(accountId, amount, context);
                    Assert.False(actual);
                };
                var account = context.Accounts.Where(a => a.AccountId == temporaryAccount.AccountId).SingleOrDefault();
                // Assert
                Assert.Equal(expected, account.Balance);
            }
        }
Пример #8
0
        public AccountHandlerTests()
        {
            _accountRepository = Substitute.For <IAccountRepository>();
            _uow = Substitute.For <IUnitOfWork>();

            _accountHandler = new AccountHandler(_accountRepository, _uow);
        }
Пример #9
0
 public LoginCommand(string email, string password, bool rememberMe, SignInManager <ApplicationUser> signInManager)
 {
     Email          = email;
     Password       = password;
     RememberMe     = rememberMe;
     AccountHandler = new AccountHandler(signInManager);
 }
Пример #10
0
        public void RegisterHandler(AccountHandler handler)
        {
            Delegate newHandler = Delegate.Combine(handler, this.handler);

            this.handler = newHandler as AccountHandler;
            // this.handler += handler;
        }
        public void AccountHandler_SendMoney_Succesfull()
        {
            var  accountService = new Moq.Mock <IAccountService>();
            var  accountHandler = new AccountHandler(accountService.Object);
            var  transactionId  = Guid.NewGuid();
            Guid accountId      = Guid.NewGuid();
            var  account        = new Models.Account();
            var  ammount        = new Models.Money();
            var  accountDetail  = new Models.AccountDetail()
            {
                Id      = accountId,
                Account = account,
                Balance = new Money()
                {
                    Total    = 1000,
                    Currency = "BRL"
                }
            };

            accountService
            .Setup(a => a.FindAccount(account))
            .Returns(accountDetail);

            accountHandler.SendMoney(account, ammount, transactionId);

            accountService.Verify(a => a.FindAccount(account), Moq.Times.Once);
            accountService.Verify(a => a.SendMoney(accountId, ammount, transactionId), Moq.Times.Once);
        }
        public void AccountHandler_BlockMoney_Succesfull()
        {
            var  accountService = new Moq.Mock <IAccountService>();
            var  accountHandler = new AccountHandler(accountService.Object);
            var  serviceId      = Guid.NewGuid();
            Guid accountId      = Guid.NewGuid();
            var  origin         = new Models.Account();
            var  accountDetail  = new Models.AccountDetail()
            {
                Id      = accountId,
                Account = origin,
                Balance = new Money()
                {
                    Total    = 1000,
                    Currency = "BRL"
                }
            };
            var ammount = new Models.Money();

            accountService
            .Setup(a => a.FindAccount(origin))
            .Returns(accountDetail);

            accountService
            .Setup(a => a.BlockAmmount(accountId, ammount))
            .Returns(serviceId);

            var transactionId = accountHandler.BlockAmmount(origin, ammount);

            Assert.Equal(serviceId, transactionId);

            accountService.Verify(a => a.FindAccount(origin), Moq.Times.Once);
            accountService.Verify(a => a.BlockAmmount(accountId, ammount), Moq.Times.Once);
        }
Пример #13
0
        public ActionResult ResetPassword(string id)
        {
            // validate
            if (string.IsNullOrWhiteSpace(id))
            {
                return(RedirectToAction("Login", "Account"));
            }

            // define request
            AccountRequest request = new AccountRequest
            {
                Data = new AccountModel
                {
                    ResetPasswordCode = id
                }
            };

            // validate reset password code
            var response = new AccountHandler(_unitOfWork, _context).ValidateResetPasswordCode(request);

            if (response.Status)
            {
                ResetPasswordModel model = new ResetPasswordModel();
                model.ResetCode = id;
                return(View(model));
            }
            else
            {
                return(RedirectToAction("Login", "Account"));
            }
        }
Пример #14
0
        public ActionResult ResetPassword(ResetPasswordModel model)
        {
            var message = "";

            if (ModelState.IsValid)
            {
                // define request
                AccountRequest request = new AccountRequest
                {
                    Data = new AccountModel
                    {
                        Password          = model.NewPassword,
                        ResetPasswordCode = model.ResetCode
                    }
                };

                // update user password
                var response = new AccountHandler(_unitOfWork, _context).UpdateUserPassword(request);
                if (response.Status)
                {
                    ViewBag.Message = Messages.UserPasswordUpdated;
                }
                else
                {
                    ViewBag.Message = Messages.UserPasswordUpdateFailed;
                }

                ViewBag.Status  = response.Status.ToString();
                ViewBag.Message = message;
            }

            return(View(model));
        }
Пример #15
0
 /// <summary>
 /// 获取当前的用户的iD跟UserName
 /// </summary>
 /// <returns></returns>
 public SmsAccountInfo GetCurrentUser()
 {
     if (!string.IsNullOrEmpty(Cookie.GetCookie("userid")))
     {
         SmsAccountInfo user       = new SmsAccountInfo();
         var            httpCookie = Cookie.GetCookie("userid");
         if (httpCookie != null)
         {
             user.ID = int.Parse(httpCookie);
         }
         var cookie = Cookie.GetCookie("account");
         if (cookie != null)
         {
             user.Account = cookie;
         }
         if (Session.GetSession(AppContent.USER_KEY) == null)
         {
             AccountHandler handler = new AccountHandler();
             user = handler.GetAccount(user.ID);
             Session.SetSession(AppContent.USER_KEY, user);
         }
         else
         {
             user = Session.GetSession(AppContent.USER_KEY) as SmsAccountInfo;
             if (user.ID != int.Parse(httpCookie))
             {
                 AccountHandler handler = new AccountHandler();
                 user = handler.GetAccount(int.Parse(httpCookie));
                 Session.SetSession(AppContent.USER_KEY, user);
             }
         }
         return(user);
     }
     return(null);
 }
Пример #16
0
 public static void fileSeeker(object state)
 {
     FileSeekFunc.timer     = DateTime.Now;
     FileSeekFunc.fileCount = 0;
     Notify += NotifyDisplayMessage;
     #region проверка правописания маски файла
     string file_mask = Program.F1.textBox2.Text;
     foreach (Char invalid_char in Path.GetInvalidFileNameChars())
     {
         if (invalid_char != '?' && invalid_char != '*')
         {
             file_mask = file_mask.Replace(invalid_char.ToString(), "");
         }
     }
     Dispatcher.Invoke(Program.F1, () =>
     {
         Program.F1.textBox2.Text = file_mask;
     });
     #endregion
     ManualResetEvent MRE = (ManualResetEvent)state;
     MRE.WaitOne();
     List <List <string> > myfileheap = new List <List <string> >();
     //добавил чтобы просто была коллекция файлов и их можно было куда то еще деть\обработать, можно убрать
     try
     {
         dirseeker(Program.F1.textBox1.Text, myfileheap);
     }
     catch
     {
         //MessageBox.Show(excpt.Message, "Error", MessageBoxButtons.YesNo);
     }
     Notify?.Invoke(FileSeekFunc.fileCount, "Поиск Окончен");
     //MessageBox.Show("jr", "Error", MessageBoxButtons.YesNo);
 }
Пример #17
0
        public AuthResult Login(LoginRequest loginRequest)
        {
            AuthResult authResult = new AuthResult();

            try
            {
                authResult = AccountHandler.Login(loginRequest);
                if (authResult.AuthStatus == AuthStatus.OK)
                {
                    authResult = JWTHandler.CreateToken(authResult);
                }
            }

            catch (Exception ex)
            {
                Logger.LogException(ex);
                authResult.AuthStatus = AuthStatus.ERROR;
            }

            if (authResult.AuthStatus != AuthStatus.OK)
            {
                ServiceHelper.ThrowBadRequest <AuthResult>(Request, authResult);
            }


            return(authResult);
        }
Пример #18
0
        public AuthResult ChangePassword(ChangePwdRequest changePwdRequest)
        {
            AuthResult authResult = null;

            try
            {
                int userId = ServiceHelper.CurrentUserId;
                authResult = AccountHandler.ChangePassword(userId, changePwdRequest.CurrentPwd, changePwdRequest.NewPassword);

                if (authResult.AuthStatus == AuthStatus.OK)
                {
                    authResult = JWTHandler.CreateToken(authResult);
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                authResult.AuthStatus = AuthStatus.ERROR;
            }

            if (authResult.AuthStatus != AuthStatus.OK)
            {
                ServiceHelper.ThrowBadRequest <AuthResult>(Request, authResult);
            }

            return(authResult);
        }
Пример #19
0
        public AuthResult New(NewRequest newRequest)
        {
            AuthResult authResult = null;

            try
            {
                authResult = AccountHandler.CreateUser(newRequest);
                if (authResult.AuthStatus == AuthStatus.OK)
                {
                    authResult = this.Login(new LoginRequest()
                    {
                        UserName = newRequest.Email, Password = newRequest.Password
                    });
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                authResult.AuthStatus = AuthStatus.ERROR;
            }

            if (authResult.AuthStatus != AuthStatus.OK)
            {
                ServiceHelper.ThrowBadRequest <AuthResult>(Request, authResult);
            }

            return(authResult);
        }
Пример #20
0
        static void Main(string[] args)
        {
            Console.WriteLine("委派的实现");

            // 实现委派的类,需要初始化.
            AccountHandler handle = new AccountHandler();
            // 初始化 需要委派实现的类
            AccountService service = new AccountService();


            // 创建委派.
            // 和创建一个普通的类对象差别不大
            // 要求是 构造函数中, 要指定 一个 方法
            // 这个方法的定义,需要与 委派的方法  参数、返回值 一致。
            AccountService.AddAccountCashDelegate add =
                new AccountService.AddAccountCashDelegate(handle.AddCash);
            // 同上
            AccountService.SubAccountCashDelegate sub =
                new AccountService.SubAccountCashDelegate(handle.SubCash);



            // 使用委派 : 将方法 作为 参数,执行操作.
            service.DemoAdd(add, 1000.20);

            service.DemoSub(sub, 0.20);


            Console.ReadLine();
        }
Пример #21
0
        public async Task ItShouldReturnAViewAndModelOnSuccess()
        {
            var reponse = new AccountDetailOrganisationsResponse
            {
                Account = new Core.Models.Account
                {
                    AccountId      = 123,
                    DasAccountName = "Test Account",
                    DateRegistered = DateTime.Today,
                    OwnerEmail     = "*****@*****.**"
                },
                StatusCode = SearchResponseCodes.Success
            };
            var id = "123";

            AccountHandler.Setup(x => x.FindOrganisations(id)).ReturnsAsync(reponse);
            var actual = await Unit.Index("123");

            Assert.IsNotNull(actual);
            Assert.IsNotNull(actual);
            Assert.IsInstanceOf <ViewResult>(actual);
            Assert.AreEqual("", ((ViewResult)actual).ViewName);
            Assert.IsInstanceOf <AccountDetailViewModel>(((ViewResult)actual).Model);
            Assert.AreEqual(reponse.Account, ((AccountDetailViewModel)((ViewResult)actual).Model).Account);
            Assert.IsNull(((AccountDetailViewModel)((ViewResult)actual).Model).SearchUrl);
        }
Пример #22
0
 private void MenuFlyoutItem_Click_1(object sender, RoutedEventArgs e)
 {
     AccountHandler.LogOff();
     _navigationHandler.NavigateFrame(Type.GetType($"{Application.Current.GetType().Namespace}.Views.{"Store"}"));
     PageNameTextblock.Text =
         Type.GetType($"{Application.Current.GetType().Namespace}.Views.{"Store"}").Name;
     //Frame.BackStack.Clear(); <- Needs implementation
 }
Пример #23
0
 /// <summary>
 /// Method that creates an account with the entered information and stores it into relevant files
 /// </summary>
 public void Confirm()
 {
     TempDisplayName        = AccountHandler.DisplayNameAddTag(_tempDisplayName);
     AccountHandler.Account = new Account(_tempUsername, TempPassword, TempDisplayName);
     AccountHandler.CreateAccount(AccountHandler.Account, TempProfilePicturePath);
     AccountList.AddAccountToFile();
     SetDisplayNameForUI = AccountHandler.Account.DisplayName;
 }
Пример #24
0
        private AuthStatus LoginGeral(LoginViewModel model)
        {
            AuthResult result = new AuthResult();

            if (!ModelState.IsValid)
            {
                return(AuthStatus.ERROR);
            }

            result = AccountHandler.Login(new LoginRequest()
            {
                UserName    = model.Email,
                Password    = model.Password,
                TokenMobile = model.tokenMobile,
                Device      = model.tipoDispositivo
            });

            WorkerEntity worker = WorkerRepository.Instance.GetByUserId(result.UserId);

            if (result.AuthStatus == AuthStatus.OK)
            {
                var claims = new List <Claim>();
                claims.Add(new Claim(ClaimTypes.Sid, result.UserId.ToString()));
                claims.Add(new Claim(ClaimTypes.Name, result.UserId.ToString()));
                claims.Add(new Claim(ClaimTypes.Email, model.Email));
                claims.Add(new Claim(ClaimTypes.NameIdentifier, result.UserId.ToString()));
                claims.Add(new Claim("http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider", "http://vlast.com.br"));

                bool isSystemAdmin = false;
                foreach (var role in result.UserRoles)
                {
                    if (role == Roles.ADMINISTRATOR)
                    {
                        isSystemAdmin = true;
                    }

                    claims.Add(new Claim(ClaimTypes.Role, role.ToString()));
                }


                if (!isSystemAdmin)
                {
                    //WorkerEntity worker = WorkerRepository.Instance.GetByUserId(result.UserId);
                    WorkerTypeEntity profile = WorkerTypeRepository.Instance.GetById(worker.WorkerTypeId);
                    claims.Add(new Claim(ClaimTypes.Role, profile.ProfileName.ToString()));
                }

                var identity = new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCookie);

                var ctx = Request.GetOwinContext();
                var authenticationManager = ctx.Authentication;
                authenticationManager.SignIn(identity);

                return(AuthStatus.OK);
            }

            return(AuthStatus.ERROR);
        }
Пример #25
0
		public AccountHandlerTests()
		{
			_accountCollection = new AccountCollectionMock();
			_bus = new TpBusMock();
			_pluginContextMock = new PluginContextMock();
			_accountHandler = new AccountHandler(_accountCollection, _bus, _pluginContextMock,
			                                     new TpLogManager(new ActivityLogPathProvider(), _pluginContextMock),
			                                     ObjectFactory.GetInstance<TransportMock>());
		}
Пример #26
0
        public bool IsOwner(Mobile m)
        {
            if (m == Owner || m.AccessLevel >= AccessLevel.GameMaster)
            {
                return(true);
            }

            return(AccountHandler.CheckAccount(m, Owner));
        }
Пример #27
0
 void Awake()
 {
     _instance             = this;
     accountHandler        = GameObject.Find("net").GetComponent <AccountHandler>();
     accountHandler.Login += Login;
     accountHandler.Reg   += Reg;
     StartBtn.BtnAddListener(StartBtnClick);
     text.text = NetIO.Instance.ip;
 }
Пример #28
0
        public ActionResult CheckToken()
        {
            AccountHandler handler    = new AccountHandler();
            var            apiToken   = Request.Headers.Get("apiToken");
            var            email      = Request.Headers.Get("email");
            var            tokenValid = handler.isTokenValid(apiToken, email);

            return(tokenValid ? new HttpStatusCodeResult(HttpStatusCode.OK) : new HttpStatusCodeResult(HttpStatusCode.Unauthorized));
        }
Пример #29
0
        public AccountTest()
        {
            _mockStore           = new InMemoryEventStore();
            _mockStoreConnection = _mockStore.Connect("Accounts");
            var eventSerializer = new JsonEventSerializer();

            _repo    = new StreamStoreRepository(new PrefixedCamelCaseStreamNameBuilder(), _mockStoreConnection, eventSerializer);
            _service = new AccountHandler(_repo);
        }
Пример #30
0
 public MobaClient(InitRequest initRequest) : base(initRequest)
 {
     account = new AccountHandler();
     player  = new PlayerHandler();
     select  = new SelectHandler();
     fight   = new FightHandler();
     player.StartSelectEvent += select.StartSelect;
     select.StartFightEvent   = fight.StartFight;
 }
		public AccountHandlerTests()
		{
			_accountCollection = new AccountCollectionMock();
			_bus = new TpBusMock();
			_pluginContextMock = new PluginContextMock();
			_accountHandler = new AccountHandler(_accountCollection, _bus, _pluginContextMock,
			                                     new TpLogManager(new ActivityLogPathProvider(), _pluginContextMock),
			                                     ObjectFactory.GetInstance<TransportMock>());
		}