public ActionResult <EstimateResponseModel> GetEstimate([FromForm] EstimateRequestModel estimateModel) { try { var estimate = GetEstimateModelFromRequestModel(estimateModel); if (estimate != null) { estimateBusiness.CalculateEstimate(estimate); return(Ok(new EstimateResponseModel { Estimate = estimate, Status = EstimationApplicationConstant.OkStatus, Message = EstimationApplicationConstant.EstimationCalculationSuccessful })); } else { return(BadRequest(EstimationApplicationConstant.CustomerNotFound)); } } catch (Exception ex) { logger.LogError(ex.Message); return(BadRequest()); } }
private EstimationModel GetEstimateModelFromRequestModel(EstimateRequestModel estimateRequestModel) { CustomerModel cust = userBusiness.FindCustomerByUserName(GetUserNameFromJwtToken()); if (cust != null) { return(new EstimationModel { Customer = cust, GoldPricePerGram = estimateRequestModel.GoldPricePerGram, WeightInGram = estimateRequestModel.WeightInGram }); } return(null); }