protected virtual async Task Create(CreateOrEditEstimateDetailDto input) { var estimateDetail = ObjectMapper.Map <EstimateDetail>(input); if (AbpSession.TenantId != null) { estimateDetail.TenantId = (int?)AbpSession.TenantId; } await _estimateDetailRepository.InsertAsync(estimateDetail); }
public async Task CreateOrEdit(CreateOrEditEstimateDetailDto input) { decimal discountPrice = 0, taxPrice = 0; decimal markUp = input.MarkUp; decimal unitPrice = input.UnitPrice; decimal quantity = input.Quantity; decimal tax = input.Tax; decimal discount = input.Discount; decimal costPrice = unitPrice * quantity; if (markUp > 0) { costPrice += costPrice * (markUp / 100); } if (discount > 0) { discountPrice = costPrice * (discount / 100); } if (tax > 0) { taxPrice = (costPrice - discountPrice) * (tax / 100); } input.Cost = costPrice; input.Charge = (costPrice - discountPrice) + taxPrice; if (input.Id == null) { await Create(input); } else { await Update(input); } }
protected virtual async Task Update(CreateOrEditEstimateDetailDto input) { var estimateDetail = await _estimateDetailRepository.FirstOrDefaultAsync((int)input.Id); ObjectMapper.Map(input, estimateDetail); }