/// <summary> /// Get the CustomerPaymentTerms Details By CustomerPaymentTermsId /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <CustomerPaymentTermUnitDto> GetCustomerPayTermUnitsById(IdInput input) { CustomerPaymentTermUnit customerPaytermUnit = await _customerPaymentTermUnitRepository.GetAsync(input.Id); CustomerPaymentTermUnitDto result = customerPaytermUnit.MapTo <CustomerPaymentTermUnitDto>(); result.CustomerPaymentTermId = customerPaytermUnit.Id; return(result); }
/// <summary> /// Validating CustomePaymentterms /// </summary> /// <param name="customePaymentUnit"></param> /// <returns></returns> protected virtual async Task ValidateCustomerPaymentTermUnitAsync(CustomerPaymentTermUnit customePaymentUnit) { //Validating if Duplicate CustomerPaymentTem exists if (CustomerPaymentTermUnitRepository != null) { var customerPaymentTermunit = (await CustomerPaymentTermUnitRepository.GetAllListAsync(p => p.Description == customePaymentUnit.Description && p.OrganizationUnitId == customePaymentUnit.OrganizationUnitId)); if (customePaymentUnit.Id == 0) { if (customerPaymentTermunit.Count > 0) { throw new UserFriendlyException(L("Duplicate CustomerPaymentTem", customePaymentUnit.Description)); } } else { if (customerPaymentTermunit.FirstOrDefault(p => p.Id != customePaymentUnit.Id && p.Description == customePaymentUnit.Description) != null) { throw new UserFriendlyException(L("Duplicate CustomerPaymentTem", customePaymentUnit.Description)); } } } }
/// <summary> /// Updating CustomerPaymentTerm Details /// </summary> /// <param name="customerPaymentTermUnit"></param> /// <returns></returns> public virtual async Task UpdateAsync(CustomerPaymentTermUnit customerPaymentTermUnit) { await ValidateCustomerPaymentTermUnitAsync(customerPaymentTermUnit); await CustomerPaymentTermUnitRepository.UpdateAsync(customerPaymentTermUnit); }