public async Task <IActionResult> SalesInfo(SalesInfoViewModel salesInfo) { try { Customer customer = Mapper.Map <Customer>(salesInfo); Models.Metrics.Inventory inventory = Mapper.Map <Models.Metrics.Inventory>(salesInfo); Models.Metrics.Inventory original = await _metricRepository.UpdateSalesInfo(inventory); customer.InventoryId = original.Id; customer.OPInventoryId = original.OPInventoryId; _metricRepository.AddCustomer(customer); if (!await _metricRepository.SaveChangesAsync()) { return(BadRequest()); } return(Ok()); } catch (Exception ex) { _logger.LogError($"An error occurred when saving sales info (Error Message: {ex}"); } return(BadRequest()); }