public void FillFees(ICollection<AppraiserFee> fees, FeesViewModel feesViewModel) { if (fees == null) { throw new ArgumentNullException("fees"); } if (feesViewModel == null) { throw new ArgumentNullException("fees view model"); } var feesArray = fees.ToArray(); foreach (var fee in feesArray) { if (!feesViewModel.FeesItems.Any(f => f.Id == fee.Id.ToString())) { fees.Remove(fee); } } foreach (var item in feesViewModel.FeesItems) { if (string.IsNullOrEmpty(_refManager.GetProductNameById(item.ProductType))) { throw new ArgumentException("product id"); } var fee = fees.SingleOrDefault(e => e.Id.ToString() == item.Id); if (fee == null) { fee = new AppraiserFee(); fees.Add(fee); } fee.Amount = item.Fee.Value; fee.ProductId = item.ProductType; } }
public void SaveFeeItem(AppraiserUser currentUser, FeeItemViewModel currentFee) { if (currentUser == null) throw new ArgumentNullException("appraiser user"); if (currentFee == null) throw new ArgumentNullException("currentFee"); if (string.IsNullOrEmpty(_refManager.GetProductNameById(currentFee.ProductType))) throw new ArgumentException("fee product id"); var fee = currentUser.Fees.SingleOrDefault(e => e.Id.ToString() == currentFee.Id); if (fee == null) { fee = new AppraiserFee(); currentUser.Fees.Add(fee); } fee.Amount = currentFee.Fee.Value; fee.ProductId = currentFee.ProductType; }