//Map from Entity to Dto public static SellingTransactionDto MappingDto(this SellingTransaction sellingTransaction) { return(new SellingTransactionDto { Id = sellingTransaction.Id, SellingOrderId = sellingTransaction.SellingOrderId, SellingOrder = new SellingOrderDto() { Id = sellingTransaction.SellingOrder.Id, }, ProductId = sellingTransaction.ProductId, Product = new ProductDto() { Id = sellingTransaction.Product.Id, Name = sellingTransaction.Product.Name }, Quantity = sellingTransaction.Quantity, UnitPrice = sellingTransaction.UnitPrice, TotalPrice = sellingTransaction.TotalPrice }); }
/// <summary> /// The method to create selling transaction. /// </summary> /// <param name="sellingTransaction">Selling Transaction domain object.</param> /// <returns>Return true or false; true indicates the the creation is successful.</returns> public bool CreateSellingTransaction(SellingTransaction sellingTransaction) { throw new NotImplementedException(); }
//Map from Dto to Entity public static void MappingTransaction(this SellingTransactionDto sellingTransactionDto, SellingTransaction sellingtransaction) { sellingtransaction.Id = sellingTransactionDto.Id; sellingtransaction.SellingOrderId = sellingTransactionDto.SellingOrderId; sellingtransaction.ProductId = sellingTransactionDto.ProductId; sellingtransaction.Quantity = sellingTransactionDto.Quantity; sellingtransaction.UnitPrice = sellingTransactionDto.UnitPrice; sellingtransaction.TotalPrice = sellingTransactionDto.TotalPrice; }
public IHttpActionResult CreateSellingTransaction(SellingTransaction sellingTransaction) { transactions = new TransactionsOrc(); return(Ok(transactions.CreateSellingTransaction(sellingTransaction))); }
/// <summary> /// The method to create selling transaction. /// </summary> /// <param name="sellingTransaction">Selling Transaction domain object.</param> /// <returns>Return true or false; true indicates the the creation is successful.</returns> public bool CreateSellingTransaction(SellingTransaction sellingTransaction) { return(true); }
/// <summary> /// Processes the given event <paramref name="eventData"/> /// </summary> /// <param name="eventData">Event data</param> public void Handle(TransactionSellingOrderAddedEvent eventData) { if (_writerRepository.GetById(eventData.AggregateId) != null) { return; } var stock = _stockRepository.GetById(eventData.StockId); if (stock == null) { throw new EventHandlerException($"No Stock found with id: {eventData.StockId}", typeof(TransactionSellingOrderAddedEventHandler)); } var feedbacks = _feedbackRepository.GetAll().Where(f => eventData.Feedback.Contains(f.Id)).ToList(); if (feedbacks == null) { throw new EventHandlerException("No Feedback found for the given ids", typeof(TransactionSellingOrderAddedEventHandler)); } var item = new SellingTransaction(eventData.AggregateId) { OriginalVersion = eventData.Version, Description = eventData.Description, Image = eventData.Image, Feedback = feedbacks, MAE = eventData.MAE, MFE = eventData.MFE, OrderCosts = eventData.OrderCosts, OrderDate = eventData.OrderDate, PricePerShare = eventData.PricePerShare, Stock = stock, Tag = eventData.Tag, Taxes = eventData.Taxes, Shares = eventData.Shares, Action = "Verkauf", PositionSize = eventData.PositionSize }; _writerRepository.Add(item); //Add to transaction book _transactionBook.AddEntry(new SellingTransactionBookEntry( eventData.StockId, eventData.AggregateId, eventData.OrderDate, eventData.Shares, eventData.PricePerShare, eventData.OrderCosts, eventData.Taxes)); //Feedback Proportions var overallFeedbackAmount = _writerRepository.GetAll() .Where(t => t is ISellingTransaction).Cast <ISellingTransaction>() .Sum(transaction => transaction.Feedback.Count()); foreach (var feedback in feedbacks) { var proportion = _feedbackProportionRepository.GetById(feedback.Id); proportion.FeedbackShare = _writerRepository .GetAll().Where(t => t is ISellingTransaction) .Cast <ISellingTransaction>() .SelectMany(t => t.Feedback) .Count(t => t.Id == feedback.Id); } foreach (var proportion in _feedbackProportionRepository.GetAll()) { proportion.OverallFeedbackAmount = overallFeedbackAmount; } }