core web api for POS system

Discussion in 'Programming & Software Development' started by howlingstar, Aug 20, 2018.

  1. howlingstar

    howlingstar Member

    Jun 9, 2015
    Currently I'm building the API for a custom POS system to connect and be able to list products and add to cart,checkout etc. Its all working fine for now on our development environment.

    Its currently built using .net core web API with EF 2 for the database (MSSQL). I've also including JWT for security for the POS terminals to be authorized.
    I use the async/await for most methods like addToCart, removeFromCart, CommitOrder etc

    public async Task<IActionResult> AddTicketProductToCart([FromBody]AddTicketProductToCartDTO dto)
    var query = from p in _context.transactioncart
    where p.TransactionCartId == dto.TransactionCartId
    select p;

    var transactioncart = await query.FirstOrDefaultAsync();

    Would this approve work fine when multiple POS terminals are connected to the API and doing calls at the same time? Would it cause any duplicates or dependencies in the database context?

    I've been reading on UnitOfWork and Repository patterns that might resolve this sort of complications. Is this recommended?
    Last edited: Aug 20, 2018
  2. waltermitty

    waltermitty Member

    Feb 19, 2016
    Wrap the whole query in a transaction, use addorupdate, hell, wrap the whole request pipeline in a transaction if you like. If the TransactionCartIds match, it'll be last in wins for concurrent connections.

Share This Page