public async Task <(bool Success, string Error)> SavePriceAsync(CreatePriceViewModel model, string userId) { bool success = false; string error = string.Empty; try { // determin if adding or editing Price price = null; if (model.PriceId > 0) { price = await _priceRepository.FetchBasePriceByIdAsync(model.PriceId); } if (price == null) { price = new Price { CreatedUserId = userId, CreatedUtc = DateTime.UtcNow }; } else { price.AuditUserId = userId; price.AuditUtc = DateTime.UtcNow; } // save other values price.Date = model.Date.Value; price.MetalId = model.MetalId; price.KaratId = model.KaratId; price.BuyPrice = model.BuyPrice; price.SellPrice = model.SellPrice; price.LoanPrice = model.LoanPrice; price.LoanPricePercent = model.LoanPricePercent; price.PerOunce = model.PerOunce; await _priceRepository.SavePriceAsync(price); success = true; } catch (Exception ex) { error = "Unexpected error occurred while processing your request"; _logger.LogError("AdminService.SavePriceAsync - Exception:{@Ex}", args: new object[] { ex }); } return(Success : success, Error : error); }