Bank ATM App Mockup – Implement Domain-Driven Design (DDD)

I've created this ATM app model, which I believe contains, but not completely, a multi-layered domain design architecture, a repository pattern, and a UOW pattern. In my solution I have these projects (level):

  • ATM Model (Domain Model Entity Layer)
  • ATM.Persistence (persistence layer)
  • ATM.ApplicationService (application layer)
  • ATM.ConsoleUICore (UI layer)

ATM Model (Domain Model Entity Layer)

namespace ATM.Model
{
public class BankAccount
{
public int Id { get; set; }
public string AccountName { get; set; }
public decimal Balance { get; set; }

public decimal CheckBalance()
{
    return Balance;
}

public void Deposit(int amount)
{
    // Domain logic
    Balance += amount;
}

public void Withdraw(int amount)
{
    // Domain logic
    //if(amount > Balance)
    //{
    //    throw new Exception("Withdraw amount exceed account balance.");
    //}

    Balance -= amount;
}
}
}

namespace ATM.Model
{
public class Transaction
{
public int Id { get; set; }
public int BankAccountId { get; set; }
public DateTime TransactionDateTime { get; set; }
public TransactionType TransactionType { get; set; }
public decimal Amount { get; set; }
}

public enum TransactionType
{
Deposit, Withdraw
}
}

ATM.Persistence (persistence layer)

namespace ATM.Persistence.Context
{
public class AppDbContext : DbContext
{        
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
    optionsBuilder.UseSqlServer(@"(connstring)");
}

public DbSet BankAccounts { get; set; }
public DbSet Transactions { get; set; }
}
}

namespace ATM.Persistence.Repository
{
public class RepositoryBankAccount
{
public AppDbContext context { get; }

public RepositoryBankAccount()
{
    context = new AppDbContext();
}

public BankAccount FindById(int bankAccountId)
{
    return context.BankAccounts.Find(bankAccountId);
}

public void AddBankAccount(BankAccount account)
{
    context.BankAccounts.Add(account);
}

public void UpdateBankAccount(BankAccount account)
{
    context.Entry(account).State = EntityState.Modified;
}
}
}

namespace ATM.Persistence.Repository
{
public class RepositoryTransaction
{
private readonly AppDbContext context;

public RepositoryTransaction()
{
    context = new AppDbContext();
}

public void AddTransaction(Transaction transaction)
{
    context.Transactions.Add(transaction);
}
}
}

ATM.ApplicationService (application layer)

namespace ATM.ApplicationService
{
public class AccountService
{        
private readonly UnitOfWork uow;

public AccountService()
{            
    uow = new UnitOfWork();
}

public void DepositAmount(BankAccount bankAccount, int amount)
{            
    bankAccount.Deposit(amount);
    uow.BankAccounts.UpdateBankAccount(bankAccount);

    var transaction = new Transaction()
    {
        BankAccountId = bankAccount.Id,
        Amount = amount,
        TransactionDateTime = DateTime.Now,
        TransactionType = TransactionType.Deposit
    };

    uow.Transactions.AddTransaction(transaction);

    try
    {
        uow.Commit();
    }
    catch
    {
        uow.Rollback();
    }
    finally
    {
        uow.Dispose();
    }
}

public void WithdrawAmount(BankAccount bankAccount, int amount)
{            
    bankAccount.Withdraw(amount);
    uow.BankAccounts.UpdateBankAccount(bankAccount);
    //repoBankAccount.UpdateBankAccount(bankAccount);

    var transaction = new Transaction()
    {
        BankAccountId = bankAccount.Id,
        Amount = amount,
        TransactionDateTime = DateTime.Now,
        TransactionType = TransactionType.Withdraw
    };

    uow.Transactions.AddTransaction(transaction);

    try
    {
        uow.Commit();
    }
    catch
    {
        uow.Rollback();
    }
    finally
    {
        uow.Dispose();
    }
}

public decimal CheckBalanceAmount(int bankAccountId)
{
    BankAccount bankAccount = uow.BankAccounts.FindById(bankAccountId);

    return bankAccount.CheckBalance();
}
}
}

ATM.ConsoleUICore (UI layer)

namespace ATM.ConsoleUICore
{
class Program
{
static void Main()
{
    AccountService accountService = new AccountService();
    RepositoryBankAccount repoBankAccount = new RepositoryBankAccount();

    var bankAccount = repoBankAccount.FindById(2);

    Console.WriteLine("1. Check balance");
    Console.WriteLine("2. Deposit");
    Console.WriteLine("3. Withdraw");
    Console.WriteLine("Enter option: ");
    string opt = Console.ReadLine();
    switch (opt)
    {
        case "1":
            Console.WriteLine($"Your balance is ${bankAccount.CheckBalance()}");
            break;
        case "2":
            // User to input amount.
            // Data validation to make sure amount is greater than zero.
            // Pass the input amount to Application layer.

            accountService.DepositAmount(bankAccount, 50);

            // After getting the operation status from Application service layer.
            // Print operation status here: Either success or fail
            Console.WriteLine("Deposit successfully");
            break;
        case "3":            
            break;
        default:
            break;
    }

}
}
}

What do you think of this model in terms of domain-driven design or layered architecture design and repository pattern and UOW pattern view?

CSS – How can I implement the HTML code to upload an image under the page title in Sharepoint?

I'm trying to put an image I've uploaded under the page title in SharePoint 2013 into my website assets. I have tried this so far:

.ms background image {
Background image: URL (https://collaboration-navy.forces.mil.ca/sites/navres-resnav/navreshq/cos-navres/sso-compt/WebISupport/SiteAssets/Forms/services-bi-header-2732x1536_2.jpg) ;
}

Although I do not think it's the right class to insert a picture just at the top of the page.
I would need help to find out which class this part also points to, as well as the CSS and HTML code to implement the top background image.

Many thanks.

Error CS1934 Failed to implement query pattern for source type & # 39; NavigatorCustomButtons & # 39; being found.

Friends I have a class that retrieves a value with an expression lamda of a control. This works well for me in VB .Net when it is submitted to C #. It sends me this error:
This is the code I have in a class in C #, in vB I had it in a class too, I expect your comments:

public static NavigatorCustomButton MfxDtanavGetBtn (ControlNavigator poctrlnav, string pcval)
{
// get the display button with lambda
NavigatorCustomButton aobtn = (from an object in poctrlnav.Buttons.CustomButtons, where aobject.Tag.ToString () == pcval select an object). ElementAtOrDefault (0);

return aobtn;

}

To implement inheritance in a Google Sheet

I have a leaf in Google Sheets that contains several complex formulas that are used multiple times by other sheets. In addition, these formulas are regularly improved. From now on, I will carefully copy and paste these formulas to update the Google spreadsheet manually. Is there a way to avoid this?

I had thought that the respective child worksheets referenced the corresponding formulas in the parent worksheet cells, but this does not produce the desired result – probably because the formula cells are in the parent worksheets within the parent worksheet as I want to contextually to the appropriate areas within the child.

In other words, how do I have a cell? A1 this on a formula in eg "Some Other Sheet & # 39 ;! A1 refers, so if 'Some Other Sheet'!A1 contains =C1 then A1 gets the value of his own C1 rather than 'Some Other Sheet'!C1?

This question is equivalent to implementing some sort of inheritance in Google Sheets.

c ++ – Implement a main loop with rendering in a Windows desktop application

I'm writing the beginnings of a small game engine in Visual C ++. What I have so far does not seem to update the rendering of each frame, but I do not understand where I'm wrong.

The code is mainly the boilerplate that generates Visual Studio. I've added the draw () and main_loop () functions.

#include "stdafx.h"
#include "Windows.h"

#include "Keyboard.h";
#include "Photon.h"
#include "Player2D.h"

#define MAX_LOADSTRING 100

// Global Variables:
HINSTANCE hInst;                                // current instance
HWND Window;
WCHAR szTitle(MAX_LOADSTRING);                  // The title bar text
WCHAR szWindowClass(MAX_LOADSTRING);            // the main window class name
Player2D player;
Keyboard keyboard;

// Prototypes
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
void draw ();
void main_loop ();

int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow)
  {
  UNREFERENCED_PARAMETER(hPrevInstance);
  UNREFERENCED_PARAMETER(lpCmdLine);

  // Initialize global strings
  LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
  LoadStringW(hInstance, IDC_PHOTON, szWindowClass, MAX_LOADSTRING);
  MyRegisterClass(hInstance);

  // Perform application initialization:
  if (!InitInstance (hInstance, nCmdShow))
    {
    return FALSE;
    }

  HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_PHOTON));

  MSG msg;

  // Main message loop:
  while (GetMessage(&msg, nullptr, 0, 0))
    {
    if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
      {
      TranslateMessage(&msg);
      DispatchMessage(&msg);
      }
    }

    return (int) msg.wParam;
  }

// Registers the window class.
ATOM MyRegisterClass(HINSTANCE hInstance)
  {
  WNDCLASSEXW wcex;

  wcex.cbSize = sizeof(WNDCLASSEX);

  wcex.style          = CS_HREDRAW | CS_VREDRAW;
  wcex.lpfnWndProc    = WndProc;
  wcex.cbClsExtra     = 0;
  wcex.cbWndExtra     = 0;
  wcex.hInstance      = hInstance;
  wcex.hIcon          = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_PHOTON));
  wcex.hCursor        = LoadCursor(nullptr, IDC_ARROW);
  wcex.hbrBackground  = (HBRUSH)(COLOR_WINDOW+1);
  wcex.lpszMenuName   = MAKEINTRESOURCEW(IDC_PHOTON);
  wcex.lpszClassName  = szWindowClass;
  wcex.hIconSm        = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));

  return RegisterClassExW(&wcex);
  }

// In this function, we save the instance handle in a global variable and
// create and display the main program window.
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
  {
  hInst = hInstance; // Store instance handle in our global variable

  Window = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
  CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr);

  if (!Window)
    {
    return FALSE;
    }

  ShowWindow(Window, nCmdShow);
  UpdateWindow(Window);

  return TRUE;
  }

// Processes messages for the main window.
//  WM_COMMAND  - process the application menu
//  WM_PAINT    - Paint the main window
//  WM_DESTROY  - post a quit message and return
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  {
  main_loop ();

  switch (message)
    {
    case WM_COMMAND:
      {
      int wmId = LOWORD(wParam);
      // Parse the menu selections:
      switch (wmId)
        {
        case IDM_ABOUT:
          DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
          break;

        case IDM_EXIT:
          DestroyWindow(hWnd);
          break;

        default:
          return DefWindowProc(hWnd, message, wParam, lParam);
        }
      }
    break;

    case WM_DESTROY:
      PostQuitMessage(0);
      break;

    default:
      return DefWindowProc(hWnd, message, wParam, lParam);
    }
  return 0;
  }

// Message handler for about box.
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  {
  UNREFERENCED_PARAMETER(lParam);
  switch (message)
    {
    case WM_INITDIALOG:
      return (INT_PTR)TRUE;

    case WM_COMMAND:
      if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
        {
        EndDialog(hDlg, LOWORD(wParam));
        return (INT_PTR)TRUE;
        }
      break;
    }
  return (INT_PTR)FALSE;
  }

void main_loop ()
  {
  player.x += 1;
  draw ();
  }

void draw ()
  {
  PAINTSTRUCT ps;
  HDC hdc = BeginPaint (Window, &ps);

  // clear background
  RECT screen;
  GetWindowRect (Window, &screen);
  screen.left = 0;
  screen.top = 0;
  COLORREF color_black = RGB (0, 0, 0);
  COLORREF color_red = RGB (255, 0, 0);
  HBRUSH brush_black = CreateSolidBrush (color_black);
  HBRUSH brush_red = CreateSolidBrush (color_red);
  FillRect (hdc, &screen, brush_black);

  player.position_rect ();
  FillRect (hdc, &player.render_rect, brush_red);

  EndPaint (Window, &ps);
  }

The game logic updates every frame and the game is rendered at least once (a black background with a red box representing the player). Breakpoints in the draw () function are hit in every frame, but the rendering is not updated when the player moves.

I realize that I could have started with a Direct X project, but I wanted to (at some point) try to write my own graphic code. So far, however, I have missed even the basic functionality.

Any advice would be appreciated.

events – how to implement the web browser

At Phil, try to figure out the best approach for my app.
I searched Stack for my question but did not find a complete answer.
assumptions:

  • There will be several users who can see in real time their vehicles (locations, condition, fuel), locations (state, it is planted, it is mown) and so on.
  • Player action – eg. Users click on Build / Drive and have to wait 45 minutes, for example. I want to show the user the time until the end of the action.
  • Should the action be registered in the queuing system? (RabbitMQ or something like that, generally a message queuing system)
  • After this time, the user's object should change – user receives coins or the vehicle changes its place from X to Y.
  • Remove this action from the queue and save information about the completed action in the database

Is my approach correct? Could I ask for ways to implement this? Or should I go in a completely different direction? I will be grateful for any advice!

Problem understanding how to implement Google Analytic Code

I have a website where I give information about computers. I have two analytical codes.






and




My question is, I have to read on Google's website, what they have to do, what I do not understand how to implement them … Can someone please explain to me in simple terms how to implement them, I must have both codes on every site from my website? What is the difference between effort?

Many thanks for your help!

magento2 – How to implement Owl Carousel in Luma Theme in Magento 2?

in your topic app/design/frontend/Vendor/YourTheme/requirejs-config.js Add Owl Carousel js entry:

var config = {
paths: {
    'myowl': 'Vendor_Module/js/owl.carousel'
},
 shim: {
    'myowl': {
        deps: ('jquery')
    },
}
};

Then call Owl Carousel in any Phtml or JS file as follows:

require(('jquery','myowl'),function($){
    $(document).ready(function(){

        // the below must be as per your requirement

        $("#owlslider").owlCarousel({
            navigation : true,
            autoplay: true,
            autoplayHoverPause: false,
            autoplaySpeed: 2000,
            loop: true,
            smartSpeed: 450
          });
    });
});

Hope that will help