Пример #1
0
        public Result<Account> UpdateAccount(EditAccountCommand editAccountCommand)
        {
            return Result<Account>.SafeExecute<AccountService>(result =>
            {

                using (DataContext = new RmmDataContext(RmmDataContext.CONNECTIONSTRING))
                {

                    var entityToUpdate = DataContext.Account.Log().Where(t => t.ID == editAccountCommand.id).First();

                    entityToUpdate.ID = editAccountCommand.id;
                    entityToUpdate.Name = editAccountCommand.Name;
                    entityToUpdate.BankName = editAccountCommand.BankName;
                    entityToUpdate.CreatedDate = DateTime.Now;


                    DataContext.SubmitChanges();

                    result.Value = entityToUpdate;
                }

            }, () => "error");
        }
        void HandleUpdateTaskSelected()
        {
            if (Account.IsEntityDataChanged)
            {
                var editAccountCommand = new EditAccountCommand() { BankName = Account.BankName, id = Account.Id, Name = Account.Name };
                var result = Accountservice.UpdateAccount(editAccountCommand);

                if (IsFavorite)
                    OptionService.SetFavoriteIdAccount(Account.Id);
            }

            NavigateTo("/MainPage.xaml?update=account", null);

            Dispose();
        }