Exemplo n.º 1
0
        static void Main(string[] args)
        {
            ITransaction transaction = Factory.BuildDefaultTransaction();

            transaction.Start();
            transaction.Add(new Resource());
            transaction.Add(new Resource());
            transaction.Commit();
        }
        public static void ShowMenu()
        {
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("1 - Add Transaction \n2 - Edit Transaction \n3 - Show Transaction \n4 - Delete Transaction \n5 - Salir");
            int opcion = Convert.ToInt32(Console.ReadLine());

            switch (opcion)
            {
            case 1:
                transact.Add();
                break;

            case 2:
                transact.Edit();
                break;

            case 3:
                transact.Show();
                break;

            case 4:
                transact.Delete();
                break;

            case 5:
                Environment.Exit(0);
                break;

            default:
                break;
            }
        }
        private void HandleEvent(RouteSegmentAdded request, ITransaction transaction)
        {
            _logger.LogDebug($"Handler got {request.GetType().Name} event seq no: {request.EventSequenceNumber}");

            if (AlreadyProcessed(request.EventId))
            {
                return;
            }


            if (!(_networkState.GetRouteNetworkElement(request.FromNodeId) is RouteNode fromNode))
            {
                _logger.LogError($"Route network event stream seems to be broken! RouteSegmentAdded event with id: {request.EventId} and segment id: {request.SegmentId} has a FromNodeId: {request.FromNodeId} that don't exists in the current state.");
                return;
            }


            if (!(_networkState.GetRouteNetworkElement(request.ToNodeId) is RouteNode toNode))
            {
                _logger.LogError($"Route network event stream seems to be broken! RouteSegmentAdded event with id: {request.EventId} and segment id: {request.SegmentId} has a ToNodeId: {request.ToNodeId} that don't exists in the current state.");
                return;
            }

            var routeSegment = new RouteSegment(request.SegmentId, request.Geometry, fromNode, toNode)
            {
                RouteSegmentInfo = request.RouteSegmentInfo,
                NamingInfo       = request.NamingInfo,
                MappingInfo      = request.MappingInfo,
                LifecycleInfo    = request.LifecyleInfo,
                SafetyInfo       = request.SafetyInfo
            };

            transaction.Add(routeSegment, ignoreDublicates: true);
        }
Exemplo n.º 4
0
        protected DeviceEntity GetDeviceEntity(ITransaction transaction)
        {
            if (!isDeviceEntitySet)
            {
                isDeviceEntitySet = true;

                int?id = DeviceId;
                if (id.HasValue)
                {
                    if (transaction == null)
                    {
                        deviceEntity = new DeviceEntity(id.Value);
                    }
                    else
                    {
                        deviceEntity = new DeviceEntity();
                        transaction.Add(deviceEntity);
                        deviceEntity.FetchUsingPK(id.Value);
                    }

                    if (deviceEntity.IsNew)
                    {
                        deviceEntity = null;
                    }
                }
            }

            // Return DeviceEntity. Can be null if not authenticated or device not found.
            return(deviceEntity);
        }
Exemplo n.º 5
0
        public async Task <IActionResult> OnPostAsync()
        {
            await Task.Run(async() =>
            {
                string username = userManager.GetUserName(User);
                using (var transaction = context.Database.BeginTransaction())
                {
                    try
                    {
                        IEnumerable <Cart> cartitem = cartdb.GetByCartId(username);
                        var transactionOrder        = new Transac
                        {
                            Username  = username,
                            OrderDate = DateTime.Now
                        };
                        transactiondb.Add(transactionOrder);
                        await transactiondb.CommitAsync();
                        foreach (var r in cartitem)
                        {
                            var orderdetail = new OrderDetail
                            {
                                OrderId    = transactionOrder.OrderId,
                                GameId     = r.GameId,
                                PlatformId = r.PlatformId,
                                Quantity   = r.Quantity,
                            };
                            orderdetaildb.Add(orderdetail);
                            await orderdetaildb.CommitAsync();

                            //Generate code
                            for (var i = 0; i < orderdetail.Quantity; i++)
                            {
                                var codeidgenerated = Guid.NewGuid().ToString();
                                var code            = new Code
                                {
                                    CodeId     = codeidgenerated,
                                    OrderId    = orderdetail.OrderId,
                                    GameId     = orderdetail.GameId,
                                    PlatformId = orderdetail.PlatformId
                                };
                                codedb.Add(code);
                                await codedb.CommitAsync();
                            }
                        }

                        cartdb.DeleteItemInCart(username);
                        await cartdb.CommitAsync();

                        await transaction.CommitAsync();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                        await transaction.RollbackAsync();
                    }
                }
            });

            return(RedirectToPage("../u/Library"));
        }
        private void HandleEvent(RouteSegmentAdded request, ITransaction transaction)
        {
            _logger.LogDebug($"Handler got {request.GetType().Name} event seq no: {request.EventSequenceNumber}");

            if (AlreadyProcessed(request.EventId))
            {
                return;
            }


            if (!(_networkState.GetObject(request.FromNodeId) is RouteNode fromNode))
            {
                _logger.LogError($"Route network event stream seems to be broken! RouteSegmentAdded event with id: {request.EventId} and segment id: {request.SegmentId} has a FromNodeId: {request.FromNodeId} that don't exists in the current state.");
                return;
            }


            if (!(_networkState.GetObject(request.ToNodeId) is RouteNode toNode))
            {
                _logger.LogError($"Route network event stream seems to be broken! RouteSegmentAdded event with id: {request.EventId} and segment id: {request.SegmentId} has a ToNodeId: {request.ToNodeId} that don't exists in the current state.");
                return;
            }

            var envelope = GeoJsonConversionHelper.ConvertFromLineGeoJson(request.Geometry).Envelope.EnvelopeInternal;

            transaction.Add(new RouteSegment(request.SegmentId, fromNode, toNode, envelope), ignoreDublicates: true);
        }
 public IActionResult Create(Transaction model)
 {
     if (ModelState.IsValid)
     {
         _Transaction.Add(model);
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
Exemplo n.º 8
0
 /// <summary>
 /// Adds adapters for a collection of steps to the transaction.
 /// </summary>
 /// <typeparam name="TStepIdTo">The type of the destination step id.</typeparam>
 /// <typeparam name="TDataTo">The type of the destination data.</typeparam>
 /// <typeparam name="TStepIdFrom">The type of the original step id.</typeparam>
 /// <typeparam name="TDataFrom">The type of the source data.</typeparam>
 /// <param name="steps">The collection fo steps.</param>
 /// <param name="stepConverter">The step converter.</param>
 /// <param name="reverseStepConverter">The reversed step converter.</param>
 /// <param name="dataConverter">The data converter.</param>
 /// <returns>The transaction.</returns>
 public static ITransaction <TStepIdTo, TDataTo> AddAdapter <TStepIdTo, TDataTo, TStepIdFrom, TDataFrom>(
     this ITransaction <TStepIdTo, TDataTo> transaction,
     IEnumerable <ITransactionStep <TStepIdFrom, TDataFrom> > steps,
     Func <TStepIdFrom, TStepIdTo> stepConverter,
     Func <TStepIdTo, TStepIdFrom> reverseStepConverter,
     Func <TDataTo, TDataFrom> dataConverter)
 {
     return(transaction.Add(steps.Select(step => step.Adapter(stepConverter, reverseStepConverter, dataConverter))));
 }
Exemplo n.º 9
0
        /// <summary>
        /// Adds a collection of steps to the transaction.
        /// </summary>
        /// <param name="steps">The collection of steps to add.</param>
        /// <returns>The transaction.</returns>
        public static ITransaction <TStepId, TData> Add <TStepId, TData>(this ITransaction <TStepId, TData> transaction, IEnumerable <ITransactionStep <TStepId, TData> > steps)
        {
            foreach (ITransactionStep <TStepId, TData> step in steps)
            {
                transaction.Add(step);
            }

            return(transaction);
        }
        public IActionResult Create([Bind("ID,Name,Description,TransactionCategoryID,TransactionDate,CreateDate,ModyficationDate,Price,PaymentTypeID")] Transaction transaction)
        {
            if (ModelState.IsValid)
            {
                // transaction.UserID = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;

                assets.Add(transaction);
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PaymentTypeID"]         = assets.GetPaymentTypes();
            ViewData["TransactionCategoryID"] = assets.GetTransactionCategories();
            return(View(transaction));
        }
        private void HandleEvent(RouteNodeAdded request, ITransaction transaction)
        {
            _logger.LogDebug($"Handler got {request.GetType().Name} event seq no: {request.EventSequenceNumber}");

            if (AlreadyProcessed(request.EventId))
            {
                return;
            }

            var envelope = GeoJsonConversionHelper.ConvertFromPointGeoJson(request.Geometry).Envelope.EnvelopeInternal;

            transaction.Add(new RouteNode(request.NodeId, request.RouteNodeInfo?.Function, envelope, request.NamingInfo?.Name), ignoreDublicates: true);
        }
        public async Task <ActionResult> Post(TransactionUpdateDTO transaction)
        {
            if (transaction == default)
            {
                return(BadRequest(ModelState));
            }
            var result = await Transaction.Add(transaction);

            if (!result)
            {
                ModelState.AddModelError("", $"Something went wrong while saving the record {transaction.Name}.");
                return(StatusCode(500, ModelState));
            }
            var vers = HttpContext.GetRequestedApiVersion().ToString();

            return(CreatedAtRoute("GetTransaction", new { version = HttpContext.GetRequestedApiVersion().ToString(), id = transaction.Id }, transaction));
        }
        private void HandleEvent(RouteNodeAdded request, ITransaction transaction)
        {
            _logger.LogDebug($"Handler got {request.GetType().Name} event seq no: {request.EventSequenceNumber}");

            if (AlreadyProcessed(request.EventId))
            {
                return;
            }

            var routeNode = new RouteNode(request.NodeId, request.Geometry)
            {
                RouteNodeInfo = request.RouteNodeInfo,
                NamingInfo    = request.NamingInfo,
                MappingInfo   = request.MappingInfo,
                LifecycleInfo = request.LifecyleInfo,
                SafetyInfo    = request.SafetyInfo
            };

            transaction.Add(routeNode, ignoreDublicates: true);
        }
Exemplo n.º 14
0
 public ActionResult <Transaction> Add(TransactionModel transaction)
 {
     return(Ok(paymentRepository.Add(transaction)));
 }