コード例 #1
0
        public async Task <IActionResult> UpdateBuy(string itemName, [FromBody] ItemUpdateDto exItem)
        {
            try
            {
                var item = await _itemRepository.UpdateBuy(itemName, exItem.Quantity);

                return(Ok(item));
            }
            catch (Exception exUpdateBuy)
            {
                return(NotFound());
            }
        }
コード例 #2
0
        public async Task <IActionResult> UpdateSell(string itemName, [FromBody] ItemUpdateDto exItem)
        {
            try
            {
                var item = await _itemRepository.UpdateSell(itemName, exItem.Quantity);

                if (item != null)
                {
                    var currentReport = (await _reportHistoryRepository.ListAllAsync()).LastOrDefault() ?? new ReportHistory();
                    currentReport.CurrentProfit += exItem.Quantity * (item.SellPrice - item.CostPrice);
                    var reporthistory = new ReportHistory();
                    reporthistory.CurrentProfit = currentReport.CurrentProfit;
                    reporthistory.LastProfit    = currentReport.LastProfit;
                    reporthistory.LastTotal     = currentReport.LastTotal;
                    await _reportHistoryRepository.AddAsync(reporthistory);
                }
                return(Ok(item));
            }
            catch (Exception exUpdateSell)
            {
                return(NotFound());
            }
        }